PHP swfupload picture File Upload Instance Code _php tutorial

Source: Internet
Author: User
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 ...

  • Related Article

    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.