Php + ajax Implementation of Image File Upload instance code-PHP source code

Source: Internet
Author: User
At present, we often use several asynchronous file upload functions. For example, I initially used the iframe framework to achieve the same effect. In the future, the real ajax function was achieved, to the final flash + php function, I will introduce the example of ajax and iframe implementing the asynchronous file upload function. At present, we often use several asynchronous file upload functions. For example, I initially used the iframe framework to achieve the same effect. In the future, the real ajax function was achieved, to the final flash + php function, I will introduce the example of ajax and iframe implementing the asynchronous file upload function.

Script ec (2); script

Method 1: upload a file using jquery ajaxfileupload. js

In fact, it is to implement the upload of non-Refresh files. The IFRAME File Upload principle can be used.
In fact, when using PHP to upload files... You can only use $ _ FILES, but if we only use JS to retrieve its ID, as shown in..Doc ument. getElementById ('img '). $ ("# img") in the form of value or jquery cannot be uploaded in real time (but many people still do this, and I did it at the beginning ).
However, what should I do if I need to implement the so-called "Asynchronous upload" function ?? You can only use third-party components or write one by yourself (embed an IFRAME In the webpage ). However, if you are considering the development time, use a third party. Here, there is a good jQuery Ajax File Upload Component, which is "ajaxfileupload. js" whose component is: callback.
Process:

(1) Code of the front-end file: test. php

The Code is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.