Controller:
$reinfo = "fail";
$filename="";
//Important note:
//When uploading using uploadify, this sessionID will change every time,
//Change The adverse effect that occurs later is that other session values offline of the sessionID can no longer be obtained. For example, the value of Yii::app()->session['ik'] changes.
//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 sentence session_id($ pse); The function 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 Yii’s method of getting 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 is impossible to 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: