jquery ajax php No refresh upload file with matte progress bar effect Yo _php tutorial

Source: Internet
Author: User
In many projects will ask users to upload things these, since the contact with jquery and Ajax no matter what to do, first of all will think of this, I this person? is to pay more attention to customer experience, this time I am responsible for the background plate, and then there is a request for users to upload photos, of course, think of no refresh upload Ah, the general Jquery+ajax words passed to PHP data I used to use JSON, and then do not know how to put $_ The contents of the FILES array to PHP, I want to use move_uploaded_file this function to $_files[' file ' [' Tmp_name '] moved to the location I want, tmp_name is the temporary path to upload, specifically see the manual, There are a lot of records about the file in the array. Query a lot of records, to achieve no refresh upload, then some solution is to build frame to do, looked for a long time, find a plug-in, jquery, Called Jquery.form, is a form plug-in, interested students can surf the internet to see, I just say this is the implementation of this, OK, on the code:

     jquery+php Implementing Ajax File Uploads 
                               
                                                                            Add an attachment     < 
                                                                                                                                                                                                                             <0%   
                                                                                                                                                                                                                                                                                                

The response page action.php simply handles the upload and then returns as JSON data for the foreground display

 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               =[' Mypic '] [' Name ' =[' Mypic '] [' Size ' (!= "" (> 1024000 ' Picture size cannot exceed 1M '   =(, '.' (! = ". gif" &&! = ". jpg" ' Picture format is wrong! '   =(100, 999 =("Ymdhis")..
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  = "files/". Span $pics Span>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ([' mypic '] [' Tmp_name '], 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              =  (/1024,2
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   =   ' name ' =>, ' pic ' =>,< span 25< span> ' size ' => 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              json_ Encode (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ;  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

And then it's done.

There seems to be jquery.form has not been to everyone, here do not say, I have written a network disk demo, the students need to download to see.

Jquery+ajax (PHP) No refresh upload file with progress demo download

http://www.bkjia.com/PHPjc/440214.html www.bkjia.com true http://www.bkjia.com/PHPjc/440214.html techarticle in many projects will ask users to upload things these, since the contact with jquery and Ajax no matter what to do, first of all will think of this, I this person? is to pay more attention to the customer body ...

  • 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.