I have this image resizing screen:
whenIclickondownload,thisscreenappearstosavethefile,butasyoucansee,thefileappearswithouttheextension,howcanImakethefileappearwiththeextensionautomaticallywhenitissaved?
Ihavethefollowingcodetodownload:
js:
$('.js-crop').on('click',download);download=function(){//Findthepartoftheimagethatisinsidethecropboxvarcanvas,left=$('.resize-image').offset().left-$container.offset().left,top=$('.resize-image').offset().top-$container.offset().top,width=$('.resize-image').width(),height=$('.resize-image').height();canvas=document.createElement('canvas');canvas.width=width;canvas.height=height;canvas.getContext('2d').drawImage(image_target,left,top,width,height,0,0,width,height);//varsrc=$('.resize-image').attr('src');//alert(src);//canvas.toDataURL("image/png;base64");
var ImageData = canvas.toDataURL("image/png;base64");
ImageData = ImageData.replace("image/png", "image/octet-stream");
document.location.href = ImageData;
}
html:
<div class="content">
<div class="component">
<img class="resize-image" src="img/image.jpg" alt="image for resizing">
<button class="btn-crop js-crop">Download<img class="icon-crop" src="img/crop.svg"></button>
</div>
</div><!-- /content -->
Is there any way to do this? can be with php tbm if need be. this link is my full code so far: link