Javascript ajax文件上传图像获取高度和宽度

Javascript ajax文件上传图像获取高度和宽度,javascript,jquery,ajax,file-upload,Javascript,Jquery,Ajax,File Upload,我希望能够更改使用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].clie

我希望能够更改使用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");
        }
    });
});
$(函数(){
$(“#submitimage”)。单击(函数(){
var data=new FormData(),
//ClientHeight并没有得到图像的高度,而是得到了其他元素的高度。
高度=$(“#文件”)[0]。客户端高度,
宽度=$(“#文件”)[0]。clientWidth,
文件名=$(“#文件”).val();
控制台。原木(高度);
控制台。原木(宽度);
FileName=FileName.replace(“C:\\fakepath\\”,“”);
data.append('file',$('#file')[0].files[0]);
$.ajax({
类型:“POST”,
url:“upload_file.php”,
cache:false,
contentType:false,
processData:false,
数据:数据,
成功:功能(数据){
newimage=“

”; $(newimage)。附加到(“.current bulletin”); } }); });
}))

我使用console.log获取它返回的高度和宽度,它总是22x272,所以我相信clientheight是获取文件按钮高度或类似的东西


我可以从那里获取高度吗?还是在加载后以某种方式获取图像的高度,然后对其进行更改更好?

因此,对于javascript,我仍然没有找到这样做的方法,但是我给了图像一个新的img类,并在css中使其具有最大宽度:100%;尽我所能