我正在尝试使用 Play 实现 SWFUpload!框架和 Mac。使用 Mac 时出现 302 错误(上传错误:302)。我认为,这似乎来自通过获取 Play 的上传页面而发生的重定向!框架(因为它是从路由文件翻译而来的?)。
它在 Windows 上的 IE 上运行良好。
我搜索了很多,阅读了很多,但没有找到是否有特定的解决方案。有没有关于如何实现这个的建议,或者对另一个简单的文件上传器有什么建议(对于大领域,有进展)?
编辑:
我已经在我的 Macbook 上尝试了 Safari 和 Firefox,并且都以状态返回 302 上传错误。我用 IE 在 Windows 上再次尝试,它工作正常。
html(样式表)代码:
#{extends 'main.html' /}
#{set title: 'Upload Media File' /}
<script type="text/javascript" src="/public/swfupload/swfupload.js"></script>
<script type="text/javascript" src="/public/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="/public/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="/public/swfupload/handlers.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function() {
var settings = {
flash_url : "/public/swfupload/swfupload.swf",
flash9_url : "/public/swfupload/swfupload_fp9.swf",
upload_url: "doUpload",
file_post_name: "data",
post_params: {"article.id" : "${article?.id}"},
file_size_limit : "1000 MB",
file_types : "*.*",
file_types_description : "All Files",
file_upload_limit : 1,
file_queue_limit : 0,
custom_settings : {
progressTarget : "fsUploadProgress",
cancelButtonId : "btnCancel"
},
debug: false,
// Button settings
button_image_url: "/public/swfupload/TestImageNoText_65x29.png",
button_width: "65",
button_height: "29",
button_placeholder_id: "spanButtonPlaceHolder",
button_text: '<span>Start</span>',
button_text_style: ".theFont { font-size: 16; }",
button_text_left_padding: 12,
button_text_top_padding: 3,
// The event handler functions are defined in handlers.js
swfupload_preload_handler : preLoad,
swfupload_load_failed_handler : loadFailed,
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,
queue_complete_handler : queueComplete // Queue plugin event
};
swfu = new SWFUpload(settings);
};
</script>
<h2 class="title">#{get 'title' /}</h2>
<div style="clear: both;"> </div>
#{form @index(), id:'uploadForm', enctype:'multipart/form-data'}
<div class="entity">
<p>This page demonstrates a simple usage of SWFUpload. It uses the Queue Plugin to simplify uploading or cancelling all queued files.</p>
<div class="fieldset flash" id="fsUploadProgress">
<span class="legend">Upload Queue</span>
</div>
<div id="divStatus">0 Files Uploaded</div>
<div>
<span id="spanButtonPlaceHolder"></span>
<input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
</div>
</div>
#{/form}
路由文件中的入口(Articles.upload 是屏幕,doUpload 由 swfupload 调用):
GET /admin/articles/{id}/upload Articles.upload
POST /admin/articles/doUpload Articles.doUpload
编辑 2: 我也尝试了 Uploadify,它返回相同的错误。有没有人知道 Play 的解决方法!框架或与 Play 一起使用的上传器!