Im using jquery to resize an image on upload, this work fine. But my problem is that i want to send the resized image,and i want to set the data of the new image in my input file such that on submit this is sent to the server. But im not able to acheive this. each time it is sending the large file. here is my code :
<div>
<input name="photo" type="file"/>
<p><span></span></p>
<i></i>
</div>
<script>
$().ready(function() {
$("input[name*='photo']").change(function(e) {
var file = e.target.files[0];
// RESET
$('#area p span').css('width', 0 + "%").html('');
$('#area img, #area canvas').remove();
// CANVAS RESIZING
$.canvasResize(file, {
width: 300,
height: 0,
crop: false,
quality: 80,
//rotate: 90,
callback: function(data, width, height) {
// SHOW AS AN IMAGE
$('<img>').load(function() {
$(this).css({
'margin': '10px auto',
'width': width,
'height': height
}).appendTo('#area div');
}).attr('src', data);
// here i am trying to assign the resized data to my image from my input file
$(this).files[0] = data;
}
});
});
});
</script>
<script src="jqLibrary/jquery.exif.js"></script>
<script src="jqLibrary/jquery.canvasResize.js"></script>
<script src="jqLibrary/canvasResize.js"></script>
</div>