使用Ajax上传图片?上传图片、Ajax

2023-09-10 14:03:19 作者:一世繁华

这时候,我的问题是:我要上传使用文件输入图像和,而不是刷新整个我的网站,我希望有一个简单的AJAX装载机翻来翻去,几秒钟后得到一个上传的图片作为结果在同一个页面。我想,谷歌找到了我几个剧本,但我似乎并没有让他们的工作。

This time my question is the following: I want to upload images using a file input and instead of refreshing the whole I site, I want a simple AJAX loader to roll and after a few seconds get an uploaded image as a result IN THE SAME PAGE. I tried a few scripts that google found for me, but I didn't seem to get them working.

任何人都能够帮助知识或有用的东西网上有?

Anyone able to help with knowledge or something useful online?

感谢。

推荐答案

您可以轻松地使用ajaxupload将图像发送到服务器端,然后获取图像上的成功返回的功能。

You can easily use ajaxupload to send images to the server side and then get the image on the success return of the function.

 $("#form1").ajaxForm({
          target: '#preview',
          beforeSubmit: function(){
             $('.upload').after('<span class="loading-bar">Processing...</span>');
            },
          success: function (){
            $('.loading-bar').hide('slow');
            setCrop();
            },
            url: "/account/processpicture"
          }).submit();