First, unzip the downloaded Uploadify compressed package and put it in the public folder. The implementation code is as follows:
1. Frontend html part:
var img_id_upload=new Array();//Initialize the array to store the uploaded picture name
var i=0;//Initialize the array subscript
$(function() {
$('#file_upload'). uploadify({
'auto' : false,//Turn off automatic upload
'removeTimeout' : 600,//Delete the file queue 1 second after the upload is completed
'swf' : '/Public/uploadify/uploadify.swf',
' uploader' : '/_URL_/Article/uploadify',
'method' : 'post', //Method, the server can use the $_POST array to obtain data
'buttonText' : 'Select image', //Set button text
'multi' : true, //Allow multiple images to be uploaded at the same time
'uploadLimit' : 8, //Only a maximum of 10 images are allowed to be uploaded at a time
'fileTypeDesc' : 'Image Files', //Only images are allowed to be uploaded
'fileTypeExts ' : '*.gif; *.jpg; *.png',//Limit the suffix of pictures that are allowed to be uploaded
'fileSizeLimit' : '2000KB',//Limit the size of uploaded pictures
'onUploadSuccess' : function(file, data , response) { //The callback function executed after each successful upload, returns data from the server to the front end
$upload = new UploadFile(); // Instantiate upload Class
$upload->maxSize = 93145728 ;//Set the attachment upload size
$upload->saveRule =rand(1,9999);
$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg','flv','avi','mov');//Set the attachment upload type
$upload->savePath = './Uploads/';//Set the attachment upload directory
if (!$upload->upload())
{// Upload error prompt error message
$this->error($upload->getErrorMsg());
}else{// Upload successfully to obtain uploaded file information
$info = $upload->getUploadFileInfo();
}
for($i=0;$i {
$data['name']=$info[$ i]['savename'];
$data['size']=$info[$i]['size'];
$data['type']=$info[$i]['extension'];
echo $info[$i]['savename'];
$rs=$ph->add($data);
}
/*if($rs)
{
$this->success(" Success");
}else
{
$this->error("Failure");
}*/
}
Copy code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn