uploadify怎么接收上传文件后服务端返回的参数

浏览:4055 发布日期:2013/11/22 分类:求助交流 关键字: upload 文件 上传
http://www.thinkphp.cn/code/156.html
http://www.thinkphp.cn/code/151.html
参考了这两个例子,还是有不明白的地方,图片传完的怎么接受返回的信息啊,
JS里有这个代码:
function funComplete(event, ID, fileObj, response, data) {}
好像其中的response是用来接收图片处理程序页面echo出的代码的,我这里接收到的是undefined,请问这个response应该怎么定义呢,请大家指导下。
JS代码:
$(document).ready(function () {
$("#hdpic").uploadify({
'buttonText':'选择图片',
'fileExt': '*.gif;*.jpg;*.png', //允许上传的文件格式为*.jpg,*.gif,*.png
'fileTypeDesc': 'Web Image Files(.JPG,.GIF,.PNG)',
'sizeLimit': '2048000', //最大允许的文件大小为2M
'fileDataName':'uploadify',
'auto': true,
'multi':false, //是否支持多文件上传
'onCancel': funCancel, //当用户取消上传时
'onQueueComplete': funComplete, //完成上传任务
'onerror': funError, //上传发生错误时
'onFallback':noflash, //浏览器不兼容FLASH时触发
});
});
//用户取消函数
function funCancel(event, ID, fileObj, data) {
alert('您取消了'+flie.name+'的上传');
return;
}
//图片上传发生的事件
function funComplete(event, ID, fileObj, response, data) {
if (response == 0) {
alert('图片' + fileObj.name + '操作失败');
return false;
}else{
var add="<img src='"+"/10ehn/Public/upthis/hd/"+response+"'" +"style='margin-left:0px;margin-top:15px'/></img>";
$('#image').html(response);
return true;
}
}
//上传发生错误时。
function funError(event, ID, fileObj, errorObj) {
//alert('错误事件');
alert(errorObj.info);
return;
}
HPH代码
public function opload(){
//接收文件过程略
if(/*上传失败*/){echo "0";}
else{ echo "文件名";}
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>