jquery File Upload plugin: jquery HTML5 uploader

Source: Internet
Author: User
Tags array file copy file upload http post php file string valid jquery file upload

Article Introduction: Jquery HTML5 Uploader plug-ins use notes.

jquery HTML5 Uploader is a jquery file upload plugin that supports drag-and-drop uploads, but requires browsers to support HTML5 1. Download plugin http://www.igloolab.com/jquery-html5-uploader/ A specific demo can also be seen here.
2. Introduction of no documents <script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" ></script> <script type= "Text/javascript" src= "Js/jquery.html5uploader.min.js" ></script>
3. Add a drag layer on the page <div id= "Dropbox" >
4. Call method <script type= "Text/javascript" > $ (Function () {$ ("#dropbox, #multiple"). Html5uploader ({name: "foo", PostURL: "Bar.aspx"}); }); </script> PostURL is the address of the file submission, name is the names of the file information array (I personally understand)
5. Because PHP is not very familiar with, so do this effect when you do not know how to write PHP file, first print_r ($_files); You can view the information about the file you obtained, such as my: Array ([UploadedFile] => Array ([ Name] => 1111.png [type] => image/png [tmp_name] => D:\web\wamp\tmp\php81A8.tmp [ERROR] => 0 [size] => 5982 6)
) where this "UploadedFile" is the name set above. If you want to get the filename simply: $_files[' uploadedfile ' [' name '];
6. After obtaining the information of the file, we generally copy the file to the specified path, because if we do not copy the file, the uploaded file is only a temporary file, the script will disappear after execution.
so next is the statement that copies the file: move_uploaded_file (String old,string newpath); This function is the file copy function provided by PHP . where old is the file to be copied, NewPath the path and name copied to the file, so the specific statement of the above case should be: $new = './public/upload/files/'; move_uploaded_file ($_files[' uploadedfile '] [' tmp_name '], $new. $_files[' UploadedFile '] [' name ']);

Make sure that the file specified by the old is a valid upload file (that is, uploaded via the PHP HTTP POST upload mechanism). If the file is valid, it is moved to the file specified by NewPath .

Move_uploaded_file () returns False if the old is not a legitimate upload file and no action occurs.

If the old is a legitimate upload file but cannot be moved for some reason, Move_uploaded_file () will return false and a warning will be issued.



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.