当前位置:Gxlcms > PHP教程 > YiiUploadify批量上传,yiiuploadify批量_PHP教程

YiiUploadify批量上传,yiiuploadify批量_PHP教程

时间:2021-07-01 10:21:17 帮助过:3人阅读

Yii Uploadify批量上传,yiiuploadify批量


控制器:

$reinfo = "fail";
$filename="";
//重要说明:
//使用uploadify 上传时,每次这个sessionID都会改变,
//改变之后出现的不利影响就是无法再获取sessionID线下的其它session值,比如 Yii::app()->session['ik'] 值就变了。
//但是这个地方值不能变,仍要用 Yii::app()->session['ik'] 的值来作验证,
//因此一定要使用这句 session_id($pse); 作用是将sessionID改回来,与原来的sessionID一致,以便顺利获取值
//有了该值之后,原来的 sessionID 和 上传之后的 sessionID 是一致的。
//echo Yii::app()->session->sessionID; 这是Yii获取sessionID的方法
//2014-10-14 13:04 W.one
$pse = Yii::app()->request->getParam('PHPSESSION');
session_id($pse);
/*
* 如果不使用上句的话,Yii::app()->session['ik']==$who 是不可能相等的,因为sessionID变了
*/
$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');//获取的相册ikey,默认为请选择,值为空,一定要选择一个值
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:

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/973027.htmlTechArticleYii Uploadify批量上传,yiiuploadify批量 控制器: $reinfo = "fail"; $filename=""; //重要说明: //使用uploadify 上传时,每次这个sessionID都会改变, //改...

人气教程排行