Effect chart
Ps://harde.org/blog/wp-content/uploads/2010/04/swfupload01.jpg "/>
index.php file
| The code is as follows |
Copy Code |
|
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
<title>swfupload Demos- SWFObject demo</title>
<link href= ". /css/default.css "rel=" stylesheet "type=" Text/css "/>
<script type=" Text/javascript "src=". /swfupload/swfupload.js "></script>
<script type=" Text/javascript "src=" Js/swfupload.swfobject.js " ></script>
<script type= "Text/javascript" src= "Js/swfupload.queue.js" ></SCRIPT>
< Script type= "Text/javascript" src= "Js/fileprogress.js" ></SCRIPT>
<script type= "Text/javascript" src = "Js/handlers.js" ></script>
<script type= "Text/javascript"
var swfu;
Swfupload.onload = function () {
var settings = {
flash_url: ". /swfupload/swfupload.swf ",
upload_url:" upload.php ",
post_params: {
"Phpsessid": "NONE",
"Hello-world": "Here I Am",
". What": " OKAY "
},
file_size_limit: MB,
file_types:" *.jpg;*.gif;*.png;* . jpeg; ",
file_types_description:" All Files ",
file_upload_limit:100,
file_queue_limit:0,
custom_settings: {
progresstarget: " Fsuploadprogress ",
cancelbuttonid:" Btncancel "
,
debug: False,
//button Settings
button_image_url: "Xpbuttonuploadtext_61x22.png",
button_placeholder_id: "Spanbuttonplaceholder",
button_width:61,
button_ Height:22,
The event handler functions are defined in Handlers.js
Swfupload_loaded_handler:swfuploadloaded,
File_queued_handler:filequeued,
File_queue_error_handler:filequeueerror,
File_dialog_complete_handler:filedialogcomplete,
Upload_start_handler:uploadstart,
Upload_progress_handler:uploadprogress,
Upload_error_handler:uploaderror,
Upload_success_handler:uploadsuccess,
Upload_complete_handler:uploadcomplete,
Queue_complete_handler:queuecomplete,//Queue plugin Event
SWFObject settings
Minimum_flash_version: "9.0.28",
Swfupload_pre_load_handler:swfuploadpreload,
Swfupload_load_failed_handler:swfuploadloadfailed
};
SWFU = new SWFUpload (settings);
}
</script>
<body>
<div id= "Header" >
<H1 id= "logo" ><a href= ". /">SWFUpload</a>
<div id= "Version" >v2.2.0</div>
</div>
<div id= "Content" >
<form id= "Form1" action= "index.php" method= "post" enctype= "Multipart/form-data" >
<p> This page demonstrates the SWFObject plugin. Do each of the following (one in a time) to the plugin work: </p>
<ul>
<li>uninstall your Flash Player or install a version less than 9.0.28</li>
<li>cause the SWF file to fail to load by deleting or renaming swfupload.swf (simulating a very slow or failed downl Oad) </li>
<li>disable javascript</li>
</ul>
<p>
Each of this tests demontrate how to issues can be handled by SWFUpload and SWFObject.
</p>
<div id= "Divswfuploadui" >
<div class= "FieldSet flash" id= "fsuploadprogress" >
<span class= "Legend" >upload queue</span>
</div>
<p id= "Divstatus" >0 Files uploaded</p>
<p>
<span id= "Spanbuttonplaceholder" ></span>
<input id= "btncancel" type= "button" value= "Cancel all uploads" disabled= "disabled" style= "MARGIN-LEFT:2PX; height:22px; font-size:8pt; "/>
<br/>
</p>
</div>
<noscript>
<div style= "Background-color: #FFFF66; Border-top:solid 4px #FF9966; Border-bottom:solid 4px #FF9966; margin:10px 25px; padding:10px 15px; " >
We ' re sorry. SWFUpload could not load. You are must have JavaScript enabled to enjoy swfupload.
</div>
</noscript>
<div id= "divloadingcontent" class= "Content" style= "Background-color: #FFFF66; Border-top:solid 4px #FF9966; Border-bottom:solid 4px #FF9966; margin:10px 25px; padding:10px 15px; Display:none; " >
SWFUpload is loading. Please wait a moment ...
</div>
<div id= "divlongloading" class= "Content" style= "Background-color: #FFFF66; Border-top:solid 4px #FF9966; Border-bottom:solid 4px #FF9966; margin:10px 25px; padding:10px 15px; Display:none; " >
SWFUpload is taking a long time to load or the load has failed. Please do sure that the Flash Plugin are enabled and that's a working version of the Adobe Flash Player is installed.
</div>
<div id= "divalternatecontent" class= "Content" style= "Background-color: #FFFF66; Border-top:solid 4px #FF9966; Border-bottom:solid 4px #FF9966; margin:10px 25px; padding:10px 15px; Display:none; " >
</div>
</form>
</div>
</body>
|
Core Processing program PHP code
| The code is 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 matters needing attention
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 in the login page to judge, if there is POST over the session_id, then use the function session_id ($_post[ ' Php_sessionid ']) specified.
Upload the page of JS inside, you can get the current session_id.
For example, upload a page in JS:
| The code is as follows |
Copy Code |
|
Post_params: {"PHPSESSID": "<?php echo session_id ();?>"}, |
In the validation page:
| The code is as follows |
Copy Code |
|
if (Isset ($_post["PHPSESSID"])) {
session_id ($_post["PHPSESSID"]);
} |
(This section is a comment on the Web: SWFUpload does not work in the background of a Web site with session validation because the SWFUpload is equivalent to reopening a new session process when uploading, so it cannot be consistent with the sessions of the original program. This needs to upload the original program SessionID, according to it to "find" its due session. )
Full instance download address: Http://file.111cn.net/download/2013/05/14/swfupload.zip