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