SWFUpload批量上传文件的问题!!!!!

qiudong_5210 2011-07-29 02:54:46
可不可以获取SWFUpload的上传状态?
我是点击上传后弹出一个页面,页面上放的SwfUpload组件,想上传完图片后,把路径返回到父窗口,并且关闭弹出的页面,
但文件上传的时候好处理,多文件上传的时候怎么处理啊?
上传页面的代码

<body style="width: 500">
<div class="sapload" style="width: 500">
<div id="saploaddiv">
</div>
<input type="hidden" id="h_name" name="h_name" />
<div style="color: #ff0000; text-indent: 4px">
请上传JPG/JPEG/PNG格式图片,上传图片每张大小不得超过1MB。</div>
</div>

<script type="text/javascript">
var so = new SWFObject("../../Content/as/sapload.swf", "sapload", "450", "25", "9", "#ffffff");
so.addVariable('types', 'jpg;JPG;jpeg,JPEG,png;PNG');
so.addVariable('args', 'myid=111;yid=222');
so.addVariable('upUrl', '../../AddImage.aspx');
so.addVariable('fileName', 'Filedata1');
so.addVariable('maxNum', '20');
so.addVariable('maxSize', '1');
so.addVariable('etmsg', '1');
so.addVariable('ltmsg', '1');
so.write("saploaddiv");
function sapLoadMsg(t) {
if (t == "no") {
alert("上传失败,每个车型最多可上传20张图片");
} else {
dialogArguments.insertHTML("<img border=0 src='http://localhost/PublishImage/" + t + "' />");

}
}
</script>

</body>
...全文
463 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
truecoffeefox 2011-07-29
  • 打赏
  • 举报
回复
官方文档还是不错的,为啥不瞅瞅啊
http://demo.swfupload.org/Documentation/
truecoffeefox 2011-07-29
  • 打赏
  • 举报
回复
因为你没有用到事件,所以不用handler,定义一下呗,上传之前可以得到文件个数,在handler用js获得

        var swfu;
window.onload = function () {
swfu = new SWFUpload({
upload_url: "upload.aspx",
post_params: {
"ASPSESSID": "<%=Session.SessionID %>"
},
assume_success_timeout: 0,
file_size_limit: "20MB",
file_types: "*.doc;*.xls;*.rar;*.zip;*.jpg;*.gif;*.png",
file_types_description: "文档",
file_upload_limit: "1",
file_queue_error_handler: fileQueueError,
file_dialog_complete_handler: fileDialogComplete,
upload_progress_handler: uploadProgress,
upload_error_handler: uploadError,
upload_success_handler: uploadSuccess,
upload_complete_handler: uploadComplete,
button_image_url: "swfupload/upload_button_small.png",
button_placeholder_id: "spanButtonPlaceholder",
button_width: 80,
button_height: 22,
button_text: '<span class="button">上传附件</span>',
button_text_style: '.button{font-size: 13pt;text-align:center} .buttonSmall{font-size: 10pt;}',
button_text_top_padding: 1,
button_text_left_padding: 0,
flash_url: "swfupload/swfupload.swf",
custom_settings: {
upload_target: "divFileProgressContainer"
},
debug: false
});
}
qiudong_5210 2011-07-29
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 truecoffeefox 的回复:]
……

JScript code

function uploadSuccess(file, serverData) {
try {
addResult(serverData);
var progress = new FileProgress(file, this.customSettings.upload_target);
……
[/Quote]

没有这个文件,有没有办法在提交之前获取到上传文件的个数?
truecoffeefox 2011-07-29
  • 打赏
  • 举报
回复
……

function uploadSuccess(file, serverData) {
try {
addResult(serverData);
var progress = new FileProgress(file, this.customSettings.upload_target);
progress.setComplete();
progress.setStatus(""); //操作已完成.
progress.toggleCancel(false);
} catch (ex) {
this.debug(ex);
}
}

function uploadComplete(file) {
try {
if (this.getStats().files_queued > 0) {
this.startUpload();
} else {
window.returnValue = filenamelist;//自己获取这个就得了
window.close();
}
} catch (ex) {
this.debug(ex);
}
}
junon 2011-07-29
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 qiudong_5210 的回复:]

引用 1 楼 truecoffeefox 的回复:
改写swfupload.handlers.js的uploadComplete事件代码即可


怎么修改??
[/Quote]
里面不是有返回的文件路径么,存贮起来,完全上传完了,再关闭窗口并传递给主窗口
qiudong_5210 2011-07-29
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 truecoffeefox 的回复:]
改写swfupload.handlers.js的uploadComplete事件代码即可
[/Quote]

怎么修改??
evil_steve 2011-07-29
  • 打赏
  • 举报
回复
同样也是在考虑 这个问题..。
baoganghan 2011-07-29
  • 打赏
  • 举报
回复
没用过,帮你顶一个
truecoffeefox 2011-07-29
  • 打赏
  • 举报
回复
改写swfupload.handlers.js的uploadComplete事件代码即可

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧