This was a few months ago. The scenario was as follows: When uploading images, I found that the image uploading method used by developers was handled by Iframe + traditional httppost. In addition, no unified upload function is set up. The code is transformed. I want to use ajax to upload images asynchronously. This technology should be quite old. As a result, the powerful cnblogs can easily find this article, which is based on the gourd painting, and the author's Labor achievements can be taken directly ". Soon the code was fully transformed. But when I publish the program to the server, the problem arises. The uploaded file is invalid! Khan ~ It is the consequence of laziness. Continue to open the previous reference article. The author explained that it can only be used locally and cannot be published to the server. I thought, do I still have to use the iframe + http post depressing method ??
As a result, I opened a more powerful google and began to search for solutions globally. Finally, I was quite frustrated. Found "jquery. form. js? 1.1.20 ".
To upload an image asynchronously, follow these steps:
1. Reference The jquery js framework (there is no need to talk about the benefits of this stuff) and then reference "jquery. form. js ".
2. Set up the general processing program ashx.
The core code is as follows:
Html:
The Code is as follows: