附件上传功能一般使用
实现,但是这个功能是在太弱,无法做到很多实际应用中需要的效果。而flash上传功能就强大很多,可以实现很多我们想要的效果。这里我就推荐一个很好的上传插件——swfupload。
swfupload是一个客户端上传工具,整合了javascript与flash技术,他的特点有:
可以同时上传多个文件;
类似AJAX的无刷新上传;
可以显示上传进度;
良好的浏览器兼容性;
兼容其他JavaScript库 (例如:jQuery, Prototype等);
支持Flash 8和Flash 9;
swfupload包括三部分的内容:swfupload.js、swfupload.swf、初始化配置参数及各种事件处理函数。所以首先在页面引入swfupload.js
然后在页面中实例化swfupload对象
var swfu;
window.onload = function() {
var settings = {
flash_url : "http://192.168.1.72/swfupload/swfupload.swf",
upload_url: "http://192.168.1.72/swfupload/upload.php", // Relative to the SWF file
post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
file_size_limit : "500 MB",
file_types : "*.jpg;*.gif;*.jpeg;*.png;*.rar;",
file_types_description : "All Files",
file_upload_limit : 100, //最大上传数量
file_queue_limit : 0,
custom_settings : {
progressTarget : "fsUploadProgress",
cancelButtonId : "btnCancel"
},
debug: false,
// Button settings
button_image_url: "images/TestImageNoText_65x29.png", // Relative to the Flash file
button_width: "65",
button_height: "29",
button_placeholder_id: "spanButtonPlaceHolder",
button_text: '浏览',
button_text_style: ".theFont