SWFUpload is a flash plug-in it can be combined with PHP to quickly implement a picture file without refreshing upload, but also can upload pictures in bulk, let me introduce you to PHP swfupload image File Upload Instance code needs to understand the reference.
index.php file
The code is as follows |
Copy Code |
SWFUpload Demos-swfobject Demo
SWFUpload v2.2.0
SWFObject Demo
|
Core handler PHP code
code as follows |
copy code |
if (Isset ($_files["Filedata"]) | |!is_uploaded_file ($_files["Filedata" ["Tmp_name"]) | | $_files["FILEDATA" ["Error" ]! = 0) { $upload _file = $_files[' Filedata '); $file _info = pathinfo ($upload _file[' name '); $file _type = $file _info[' extension '); $save = ' image/'. MD5 (Uniqid ($_files["Filedata" [' Name '])). '.' . $file _info[' extension ']; $name = $_files[' Filedata ' [' tmp_name '];
if (!move_uploaded_file ($name, $save)) { Exit }
Save the output of an array for viewing $fileName = ' test.txt '; $postData = Var_export ($file _info, true); $file = fopen (". $fileName," w "); Fwrite ($file, $postData); Fclose ($file); } |
SWFUpload precautions
Swfuplaod in the upload, will be a new process, and the original process is inconsistent, to solve this problem, you need to specify session_id, and then on the login page to judge, if there is a POST session_id, then use the function session_id ($_post[ ' Php_sessionid ']) to specify.
Upload the page JS inside, you can get the current session_id.
For example, the upload page JS:
The code is as follows |
Copy Code |
Post_params: {"PHPSESSID": " "}, |
In the validation's judgment page:
The code is as follows |
Copy Code |
if (Isset ($_post["Phpsessid")) { session_id ($_post["PHPSESSID"]); } |
(This paragraph is a comment on the Internet: in the background of the site with the session verification SWFUpload does not work, because the swfupload in the upload as the equivalent of re-opened a new session process, and therefore cannot be consistent with the original program session, This requires the SessionID of the original program to be passed on the upload, which will "retrieve" its due session. )
Full instance download address: Http://file.php100.com/download/2013/05/14/swfupload.zip
http://www.bkjia.com/PHPjc/444604.html www.bkjia.com true http://www.bkjia.com/PHPjc/444604.html techarticle SWFUpload is a flash plug-in it can be combined with PHP to quickly implement a picture file without refreshing upload, but also can upload pictures in bulk, let me introduce you to the PHP swfupload picture file ...