search
Homephp教程php手册Yii Uploadify批量上传,yiiuploadify批量

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:

 

//当用户选定文件,点确定后触发,每个文件将会触发一次
'onSelect':function(file){

},

'onUploadStart' : function(file) {
$("#xceimgs2").uploadify("settings", "formData",{'zlsjm':$("#juece_zlsjm").val(),'zlikey':$("#juece_zlikey").val()});
},

'onUploadSuccess':function(file, data, response){
json=eval("("+data+")");
//alert(json["name"]);return false;
//不等于fail表明上传成功
if(json.info!="fail"){
$("#jueceim"+ii).attr("src","");
$("#jueceb"+ii).text(json.name);
$("#juecedele"+ii).attr("src","");
$("#juecedele"+ii).attr("value",json.info);
ii++;
}
},

//返回一个错误,选择文件的时候触发
'onSelectError':function(file, errorCode, errorMsg){
switch(errorCode) {
case -100:
alert("上传的文件数量已经超出系统限制的 50 个文件!");
break;
case -110:
alert("文件 ["+file.name+"] 大小超出系统限制的"+$('#xceimgs2').uploadify('settings','fileSizeLimit')+"大小!");
break;
case -120:
alert("文件 ["+file.name+"] 大小异常!");
break;
case -130:
alert("文件 ["+file.name+"] 类型不正确!");
break;
default:
}
}
});
});

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),