同样的一个文件代码,不同的访问路径出现不同的效果,使用控制器路径访问一问题:
效果如图


代码如下:
<html>
<head>
<meta charset='utf-8'>
<title>ok</title>
<script src="/demo/hlds/Public/uploadify/jquery.min.js" type="text/javascript"></script>
<script src="/demo/hlds/Public/uploadify/jquery.uploadify-3.1.min.js" type="text/javascript" ></script>
<link rel="stylesheet" type="text/css" href="/demo/hlds/Public/uploadify/uploadify.css">
<script type="text/javascript">
var img_id_upload=new Array();//初始化数组,存储已经上传的图片名
var i=0;//初始化数组下标
$(function() {
$('#file_upload').uploadify({
'auto' : false,//关闭自动上传
'removeTimeout' : 0,//文件队列上传完成1秒后删除
'swf' : '/demo/hlds/Public/uploadify/uploadify.swf',
'uploader' : '/demo/hlds/Public/uploadify/uploadify.php',
'method' : 'post',//方法,服务端可以用$_POST数组获取数据
'buttonText' : '添加附件',//设置按钮文本
'multi' : true,//允许同时上传多张图片
'uploadLimit' : 10,//一次最多只允许上传10张图片
'fileTypeDesc' : 'Image Files',//只允许上传图像
'fileTypeExts' : '*.gif; *.jpg; *.png; *.docx;',//限制允许上传的图片后缀
'fileSizeLimit' : '20000KB',//限制上传的图片不得超过200KB
'onUploadSuccess' : function(file, data, response) {//每次成功上传后执行的回调函数,从服务端返回数据到前端
img_id_upload[i]=data;
i++;
if (data=''){
alert(data);
}
},
'onQueueComplete' : function(queueData) {//上传队列全部完成后执行的回调函数
if(img_id_upload.length>0)
alert('成功上传的文件有:'+img_id_upload);//encodeURIComponent()
}
// Put your options here
});
});
</script>
</head>
<body>
<input type="file" name="file_upload" id="file_upload" />
<!--<p><a href="javascript:$('#file_upload').uploadify('upload','*');">上传</a> -->
<!--动态传值 $('#file_upload').uploadify('settings', 'formData', {'typeCode':document.getElementById('id_file').value}); -->
<p><a href="javascript:$('#file_upload').uploadify('settings', 'formData', {'typeCode':document.getElementById('id_file').value});$('#file_upload').uploadify('upload','*')">上传</a>
<a href="javascript:$('#file_upload').uploadify('cancel','*')">重置上传队列</a>
</p>
<input type="hidden" value="1215154" name="tmpdir" id="id_file">
</body>
</html> 最佳答案