0
我希望能够改变图像的高度,用ajax上传。AJAX文件上传的图像获取的高度和宽度
这里是我的代码:
$(function(){
$("#submitimage").click(function(){
var data = new FormData(),
// ClientHeight is not getting the image height it is getting the height of some other element.
height = $("#file")[0].clientHeight,
width = $("#file")[0].clientWidth,
FileName = $("#file").val();
console.log(height);
console.log(width);
FileName = FileName.replace("C:\\fakepath\\", "");
data.append('file', $('#file')[0].files[0]);
$.ajax({
type: "POST",
url: "upload_file.php",
cache: false,
contentType: false,
processData: false,
data: data,
success: function(data) {
newimage = "<br><img src='uploadedimages/"+FileName+"' width='"+width+"' height='"+height+"' alt='new image' /><br>";
$(newimage).appendTo(".current-bulletin");
}
});
});
});
我使用的console.log得到高度和宽度它返回它总是22x272所以我相信clientheight越来越文件按钮高度或类似的东西。
我可以从那里得到的高度还是更以某种方式获得图像的高度,它被加载后,然后改变它呢?