在项目中用到了swfupload,win7下开发,完成后部署到linux下,服务器使用tomcat。
诡异的是一开始使用没问题,过一段时间客户反馈上传图片报错404。
然后我在本地机器上做验证报错500。
项目使用SSH框架开发。更诡异的是在我的struts2的action中原本有一个字段保存了值的,但是上传文件到这个action处理的时候这个字段的值变成了null。难道swfupload处理上传文件的时候还会影响action的生命周期?如果一开始就有这问题我也认了,关键是程序已经正常使用了一段时间,本来上传图片是没有问题的,action中的字段也能正常取到值的。
忘了说一点,报错归报错,实际上图片还是上传成功了。有影响的就两点,一是上传成功不该报错但是报错了,二是字段被清空为null无法使用了。
swfupload调试信息如下:
---SWFUpload Instance Info---
Version: 2.2.0 2009-03-25
Movie Name: SWFUpload_0
Settings:
upload_url: http://localhost:8080/DreamHouse/dealUpload
flash_url: swfupload/swfupload.swf?preventswfcaching=1377168738877
use_query_string: false
requeue_on_error: false
http_success:
assume_success_timeout: 0
file_post_name: Filedata
post_params: [object Object]
file_types: *.jpg;*.png;*.gif;*.jpeg
file_types_description: Image Files
file_size_limit: 200 MB
file_upload_limit: 100
file_queue_limit: 0
debug: true
prevent_swf_caching: true
button_placeholder_id: spanButtonPlaceHolder
button_placeholder: Not Set
button_image_url: /DreamHouse/images/TestImageNoText_65x29.png
button_width: 65
button_height: 29
button_text: <span class="theFont">浏览</span>
button_text_style: .theFont { font-size: 16; }
button_text_top_padding: 3
button_text_left_padding: 12
button_action: -110
button_disabled: false
custom_settings: [object Object]
Event Handlers:
swfupload_loaded_handler assigned: false
file_dialog_start_handler assigned: false
file_queued_handler assigned: true
file_queue_error_handler assigned: true
upload_start_handler assigned: true
upload_progress_handler assigned: true
upload_error_handler assigned: true
upload_success_handler assigned: true
upload_complete_handler assigned: true
debug_handler assigned: trueSWF DEBUG: SWFUpload Init Complete
SWF DEBUG:
SWF DEBUG: ----- SWF DEBUG OUTPUT ----
SWF DEBUG: Build Number: SWFUPLOAD 2.2.0
SWF DEBUG: movieName: SWFUpload_0
SWF DEBUG: Upload URL: http://localhost:8080/DreamHouse/dealUpload
SWF DEBUG: File Types String: *.jpg;*.png;*.gif;*.jpeg
SWF DEBUG: Parsed File Types: jpg,png,gif,jpeg
SWF DEBUG: HTTP Success: 0
SWF DEBUG: File Types Description: Image Files (*.jpg;*.png;*.gif;*.jpeg)
SWF DEBUG: File Size Limit: 209715200 bytes
SWF DEBUG: File Upload Limit: 100
SWF DEBUG: File Queue Limit: 100
SWF DEBUG: Post Params:
SWF DEBUG: PHPSESSID=
SWF DEBUG: ----- END SWF DEBUG OUTPUT ----
SWF DEBUG:
SWF DEBUG: Event: fileDialogStart : Browsing files. Multi Select. Allowed file types: *.jpg;*.png;*.gif;*.jpeg
SWF DEBUG: Select Handler: Received the files selected from the dialog. Processing the file list...
SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files. Files selected: 1. Files Queued: 1
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: Global Post Item: PHPSESSID=
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload. Starting upload to http://localhost:8080/DreamHouse/dealUpload for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 187174. Total: 187174
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 500.
Error Code: HTTP Error, File name: 07.jpg, Message: 500
SWF DEBUG: Event: uploadComplete : Upload cycle complete. swfupload500404
诡异的是一开始使用没问题,过一段时间客户反馈上传图片报错404。
然后我在本地机器上做验证报错500。
项目使用SSH框架开发。更诡异的是在我的struts2的action中原本有一个字段保存了值的,但是上传文件到这个action处理的时候这个字段的值变成了null。难道swfupload处理上传文件的时候还会影响action的生命周期?如果一开始就有这问题我也认了,关键是程序已经正常使用了一段时间,本来上传图片是没有问题的,action中的字段也能正常取到值的。
忘了说一点,报错归报错,实际上图片还是上传成功了。有影响的就两点,一是上传成功不该报错但是报错了,二是字段被清空为null无法使用了。
swfupload调试信息如下:
---SWFUpload Instance Info---
Version: 2.2.0 2009-03-25
Movie Name: SWFUpload_0
Settings:
upload_url: http://localhost:8080/DreamHouse/dealUpload
flash_url: swfupload/swfupload.swf?preventswfcaching=1377168738877
use_query_string: false
requeue_on_error: false
http_success:
assume_success_timeout: 0
file_post_name: Filedata
post_params: [object Object]
file_types: *.jpg;*.png;*.gif;*.jpeg
file_types_description: Image Files
file_size_limit: 200 MB
file_upload_limit: 100
file_queue_limit: 0
debug: true
prevent_swf_caching: true
button_placeholder_id: spanButtonPlaceHolder
button_placeholder: Not Set
button_image_url: /DreamHouse/images/TestImageNoText_65x29.png
button_width: 65
button_height: 29
button_text: <span class="theFont">浏览</span>
button_text_style: .theFont { font-size: 16; }
button_text_top_padding: 3
button_text_left_padding: 12
button_action: -110
button_disabled: false
custom_settings: [object Object]
Event Handlers:
swfupload_loaded_handler assigned: false
file_dialog_start_handler assigned: false
file_queued_handler assigned: true
file_queue_error_handler assigned: true
upload_start_handler assigned: true
upload_progress_handler assigned: true
upload_error_handler assigned: true
upload_success_handler assigned: true
upload_complete_handler assigned: true
debug_handler assigned: trueSWF DEBUG: SWFUpload Init Complete
SWF DEBUG:
SWF DEBUG: ----- SWF DEBUG OUTPUT ----
SWF DEBUG: Build Number: SWFUPLOAD 2.2.0
SWF DEBUG: movieName: SWFUpload_0
SWF DEBUG: Upload URL: http://localhost:8080/DreamHouse/dealUpload
SWF DEBUG: File Types String: *.jpg;*.png;*.gif;*.jpeg
SWF DEBUG: Parsed File Types: jpg,png,gif,jpeg
SWF DEBUG: HTTP Success: 0
SWF DEBUG: File Types Description: Image Files (*.jpg;*.png;*.gif;*.jpeg)
SWF DEBUG: File Size Limit: 209715200 bytes
SWF DEBUG: File Upload Limit: 100
SWF DEBUG: File Queue Limit: 100
SWF DEBUG: Post Params:
SWF DEBUG: PHPSESSID=
SWF DEBUG: ----- END SWF DEBUG OUTPUT ----
SWF DEBUG:
SWF DEBUG: Event: fileDialogStart : Browsing files. Multi Select. Allowed file types: *.jpg;*.png;*.gif;*.jpeg
SWF DEBUG: Select Handler: Received the files selected from the dialog. Processing the file list...
SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files. Files selected: 1. Files Queued: 1
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: Global Post Item: PHPSESSID=
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload. Starting upload to http://localhost:8080/DreamHouse/dealUpload for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 187174. Total: 187174
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 500.
Error Code: HTTP Error, File name: 07.jpg, Message: 500
SWF DEBUG: Event: uploadComplete : Upload cycle complete. swfupload500404
程序在上传图片之前进入过这个action,把其中是一个字段id设了值,但是上传图片到这个action进行处理的时候id变成了null。action在Spring中设置的作用域为“session”。
我想在初次进入这个action的时候把id保存到HttpSession中,处理图片上传的时候再取出来使用,但是也不行,取出来的还是null。求高手指教!
好吧,本人新手一枚,以后会注意你给的建议的。
另外使用swfupload上传文件取不到session的值原来是这个插件出于安全原因所做的限制,网上搜一下解决方案不少。这里就不写了。
唯一还没弄明白的就是为什么用一段时间才出问题。而且把swfupload.swf文件删掉重新加回来就好了。等等看有没有其他人有其他见解。周末或者下周一结帖。