jquery를 사용하여 업로드시 이미지의 크기를 조정하면 작업이 잘됩니다. 하지만 내 문제는 크기가 조정 된 이미지를 보내고 싶습니다. 그리고 제출시 서버에 전송되는 것과 같이 입력 파일에 새 이미지의 데이터를 설정하고 싶습니다. 그러나 나는 이것을 습득 할 수 없다. 대용량 파일을 전송할 때마다 여기에 내 코드 :이미지 크기를 조정하고 입력 파일로 설정
<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>
관련 https://stackoverflow.com/q/47515232/584192 –