文件上传方式一

 public String upload(){
        
        String path=ServletActionContext.getServletContext().getRealPath("/upload");
        File saveFile = new File(path, this.getFileFileName());

        // 判断是否存在同名文件
        if (saveFile.exists()) {
            return "false";
        }
        file.renameTo(saveFile);
        return null;
}
 
var upload1;

window.onload = function() {
	upload1 = new SWFUpload({
		// Backend Settings
		upload_url: "fileUploadAction.action", //处理上传请求的服务器端URL,必选
		file_post_name: "file",                   //POST过去的$_FILES的数组名,与后台file一致
		//post_params: {"picSESSID" : "songhao"}, //POST过去的参数,可选
		
		// File Upload Settings
		file_size_limit : "102400",	           //文件大小设定1024表示1M
		file_types : "*.zip",//文件上传类型,文件后缀而已
		file_types_description : "Zip Files",  //文件类型描述,文件选择框会显示,可以随便写
		file_upload_limit : "5",  //一次性最多上传文件个数,在上传过程中,该数字会累加,如果设置为0则表示没有限制
		file_queue_limit : "0",    //上传队列数量限制,该项通常不需设置,会根据file_upload_limit自动赋值

		// Event Handler Settings (all my handlers are in the Handler.js file)
		file_dialog_start_handler : fileDialogStart,
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,

		// Button Settings   button的图片
		button_image_url : "images/ico_button_File.png",
		button_placeholder_id : "spanButtonPlaceholder1",
		button_width: 100,
		button_height: 28,
		
		// Flash Settings
		flash_url : "swfupload/swfupload.swf",

		//custom_settings
		custom_settings : {
			progressTarget : "fsUploadProgress1",
			cancelButtonId : "btnCancel1",
			uploadButtonId : "btnUpload1"
		},
		
		// Debug Settings
		debug: false
	});
 }
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值