当前位置: 首页 > 工具软件 > SWFUpload > 使用案例 >

swfupload的一点用法

锺离鸿
2023-12-01
页面引用handlers.js,swfupload.js,jquery

页面js
var swfupload;
        $(function () {
            swfupload = new SWFUpload({
                upload_url: "UploadHandler.ashx",
                file_size_limit: "1000 MB",
                file_types: "*.*",
                file_types_description: "SWF File",
                file_upload_limit: 0,
                swfupload_preload_handler: preLoad,
                swfupload_load_failed_handler: loadFailed,
                file_dialog_complete_handler: fileDialogComplete,
                upload_progress_handler: uploadProgress,
                upload_error_handler: uploadError,
                upload_success_handler: uploadSuccess,
                upload_complete_handler: uploadComplete,
                button_image_url: "images/XPButtonNoText_160x22.png",
                button_placeholder_id: "spanButtonPlaceholder",
                button_width: 160,
                button_height: 22,
                button_text: '<span class="button">选择文件(立即上传)</span>',
                button_text_style: '.button { font-family: 宋体, Arial, sans-serif; font-size: 12pt; text-align:center; }',
                button_text_top_padding: 1,
                button_text_left_padding: 5,

                flash_url: "/swfupload.swf",
                flash9_url: "/swfupload_FP9.swf",

                debug: false
            });
        });

UploadHandler.ashx是接收上传内容的,主要的方法是

context.Request.Files[0].SaveAs();

另外可以输出文件的url,在handlers.js里面处理结果
handlers可以写一些时间来处理比如:选择文件时,上传的时候显示百分比,上传结束,上传完成,上传失败什么的,很多都可以在这里来处理

有个问题是ashx好像是无法得到cookie或者自己加session的?

swfupload地址:http://www.swfupload.org/
可以看看里面的demo,例子好像还挺多的


 类似资料: