To download the ZIP package first
Www.uploadify.com/wp-content/uploads/files/uploadify.zip
1, template file reference
<!--quote jquery uploady*}-->
<script src= "Http://www.hq08.cn/public/jquery.js" type= "Text/javascript" charset= "Utf-8" ></script>
<link rel= "stylesheet" type= "Text/css" href= "Http://www.hq08.cn/public/uploadify.css" media= "All" >
<script type= "Text/javascript" src= "Http://www.hq08.cn/public/jquery.uploadify.min.js" ></script>
<!--uploadify Related Settings--
<script type= "Text/javascript" >
$ (function () {
$ (' #file_upload '). Uploadify ({
' FormData ': {
' timestamp ': ' {# $timestamp #} ',
' token ': ' {# $token #} '
},
Be sure to add this code when using PHP, and avoid errors
' ButtonText ': ' Upload ',
' Multi ': true,//allows multiple file uploads
' swf ': ' public/uploadify.swf ',
' Uploader ': ' {#spUrl c=heji a=uploadify#} ',
' Onuploadsuccess ': function (file, data, response) {
$ ('. Touxiang_path '). val (data);
}
});
});
</script>
2. Add a few lines of code to the Code
<div class= "Touxiang" >
<input id= "File_upload" type= "text" name= "Touxiang" >
</div>
<div class= "Touxiang_path" >
<input id= "" type= "text" name= "Touxiang_path" class= "Touxiang_path" style= "width:500px;" >
</div>
Can modify the style arbitrarily, can be more beautiful
3,php Upload Processing
$targetFolder = '/up/';
$verifyToken = MD5 (' Unique_salt '. $_post[' timestamp ');
if (!empty ($_files) && $_post[' token ') = = $verifyToken) {
$tempFile = $_files[' Filedata ' [' tmp_name '];
$targetPath = $handler _dir. '/'. $targetFolder;
$targetFile = RTrim ($targetPath, '/'). ‘/‘ . $_files[' Filedata ' [' name '];
$fileTypes = array (' jpg ', ' jpeg ', ' gif ', ' PNG '); File Extensions
$fileParts = PathInfo ($_files[' Filedata ' [' name ']);
if (In_array ($fileParts [' extension '], $fileTypes)) {
Move_uploaded_file ($tempFile, $targetFile);
echo ' 1 ';
} else {
Echo ' Invalid file type. ';
}
}
can set the picture and file size, you can add watermarks, thumbnails, arbitrary processing of pictures, etc.
Uploadify Multi-image and file upload website application