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.