Home > Backend Development > PHP Tutorial > Yii Uploadify batch upload

Yii Uploadify batch upload

WBOY
Release: 2016-08-08 09:27:29
Original
1083 people have browsed it

Controller:

$reinfo = "fail";
$filename="";
//Important note:
//When uploading using uploadify, the sessionID will change every time,
//The adverse effect after the change is that the sessionID can no longer be obtained Other offline session values, such as the value of Yii::app()->session['ik'], have changed.
//But the value in this place cannot be changed. You still need to use the value of Yii::app()->session['ik'] for verification.
//So you must use this session_id($pse); function It is to change the sessionID back to be consistent with the original sessionID so that the value can be obtained smoothly
//With this value, the original sessionID and the sessionID after uploading are consistent.
//echo Yii::app()->session->sessionID; This is how Yii gets sessionID
//2014-10-14 13:04 W.one
$pse = Yii::app() ->request->getParam('PHPSESSION');
session_id($pse);
/*
* If the previous sentence is not used, Yii::app()->session['ik']== $who cannot be equal because the sessionID has changed
*/
$who = (int)Yii::app()->request->getParam('who');
$sjm = Yii::app ()->request->getParam('sjm');
$zlsjm = Yii::app()->request->getParam("zlsjm");
//$xceikey = (int)Yii ::app()->request->getParam('xceikey');//The obtained album ikey, the default is please select, the value is empty, be sure to select a value
if ($who==Yii:: app()->session['ik']){
$sjz = time();
$tempFile = $_FILES['Filedata'];
$checkType = pathinfo($tempFile["name"],PATHINFO_EXTENSION) ;
if ($checkType != "notimg"){
$targetPath = $_SERVER['DOCUMENT_ROOT'] . '/oa/upload/file/';
$scfile = date("Y").date("m ").date("d").date("His")."_".$who."_".md5(microtime()).".".$checkType;
$targetFile = str_replace('/ /','/',$targetPath) . $scfile;
if (move_uploaded_file($tempFile['tmp_name'],$targetFile)){
$relativeurl = "./upload/file/".$scfile;
/ /$relativeurl = $tempFile["name"];
$zlfj = new Zlfj();
$zlfj->fj_zlsjm = $zlsjm;
$zlfj->fj_uikey = Yii::app()->session ["ik"];
$zlfj->fj_path = "./upload/file/".$scfile;
$zlfj->fj_time = time();
$zlfj->fj_name = $tempFile[" name"];
if($zlfj->validate()&&$zlfj->save()){
$reinfo = $relativeurl;
$filename=$tempFile["name"];
}else{
@unlink($targetFile);
}

}
}
}
echo CJSON::encode(array("info"=>"$reinfo","name"=>$filename));

view:

The above introduces Yii Uploadify batch upload, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template