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 }); }