比起swfupload,uploadify插件配置使用都更简单,只是刚加载的时候稍微慢了一秒左右.
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>php jquery uploadify多文件上传</title>
<link href=”css/default.css” rel=”stylesheet” type=”text/css” />
<link href=”css/uploadify.css” rel=”stylesheet” type=”text/css” />
<script type=”text/javascript” src=”js/jquery-1.3.2.min.js”></script>
<script type=”text/javascript” src=”js/swfobject.js”></script>
<script type=”text/javascript” src=”js/jquery.uploadify.v2.1.0.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function() {
$(“#fileInput2″).uploadify({
‘uploader’: ‘js/uploadify.swf’,//所需要的flash文件
‘cancelImg’: ‘cancel.png’,//单个取消上传的图片
‘script’: ‘js/uploadify.php’,//实现上传的程序
‘folder’: ‘uploads’,//服务端的上传目录
//’auto’: true,//自动上传
‘multi’: true,//是否多文件上传
//’checkScript’: ‘js/check.php’,//验证 ,服务端的
‘displayData’: ‘speed’,//进度条的显示方式
//’fileDesc’: ‘Image(*.jpg;*.gif;*.png)’,//对话框的文件类型描述
//’fileExt’: ‘*.jpg;*.jpeg;*.gif;*.png’,//可上传的文件类型
//’sizeLimit’: 999999 ,//限制上传文件的大小
//’simUploadLimit’ :3, //并发上传数据
//’queueSizeLimit’ :5, //可上传的文件个数
//’buttonText’ :’文件上传’,//通过文字替换钮扣上的文字
‘buttonImg’: ‘css/images/browseBtn.png’,//替换上传钮扣
‘width’: 80,//buttonImg的大小
‘height’: 24,//
‘rollover’: true,//button是否变换
onComplete: function (evt, queueID, fileObj, response, data) {
//alert(“Successfully uploaded: “+fileObj.filePath);
//alert(response);
getResult(response);//获得上传的文件路径
}
//onError: function(errorObj) {
// alert(errorObj.info+” “+errorObj.type);
//}
});
});
</script>
<script type=”text/javascript”>
function getResult(content){
//通过上传的图片来动态生成text来保存路径
var board = document.getElementById(“divTxt”);
board.style.display=””;
var newInput = document.createElement(“input”);
newInput.type = “text”;
newInput.size = “45″;
newInput.name=”myFilePath[]”;
var obj = board.appendChild(newInput);
var br= document.createElement(“br”);
board.appendChild(br);
obj.value=content;
}
</script>
</head>
<body>
<fieldset style=”border: 1px solid #CDCDCD; padding: 8px; padding-bottom:0px; margin: 8px 0″>
<legend> <strong>多文件上传</strong></legend>
<div>
<input id=”fileInput2″ name=”fileInput2″ type=”file” />
<input type=”button” value=”确定上传” onclick=”javascript:$(‘#fileInput2′).uploadifyUpload();”>
|| <a href=”javascript:$(‘#fileInput2′).uploadifyClearQueue();”>删除列表</a></div>
<p></p>
</fieldset>
<FORM name=”form2″ METHOD=POST ACTION=”db.php”>
<div id=”divTxt” style=”display:none”><span style=”color:red”><strong>已上传的文件有:</strong>;<br></div><br>
<INPUT TYPE=”submit” value=”确定”>
</FORM>
</body>
</html>
转载请注明来源网站:blog.ytso.com谢谢!
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/14976.html