tutorial on using swfobject file upload Plugin

Source: Internet
Author: User
Tags file upload rar

It makes the insertion of flash media resources as simple and secure as possible. And it is very consistent with the principles of search engine optimization. In addition, it can avoid non-standard tags such as object, embed, and so on in your HTML and XHTML to meet more standard.

SWFObject File Upload use method records, the plug-in is very powerful and very flexible, and uploadify.
It is worth saying that if you want to set the Button_image_url this parameter, this parameter is the background of the button, but it must be 4 sheets of equal height vertical juxtaposition, the following figure.

Setting this parameter can achieve the effect of decorating the background, but you will find that the flash in the load of the picture is a delay, so the effect is that the flash can come out.

To solve this problem, we can only take a detour, and discard the use of change parameters. We will be the plug-in's container parent form to decorate, to achieve the desired results, and then the plug-in flash set wide and high, the important point is to set flash to transparent.


Button_window_mode:SWFUpload.WINDOW_MODE. Transparent

The following is the sample code ~ ~ and Description of the comments, detailed parameters or to find the Niang bar, the online article slightly different.

<script type= "Text/javascript" >
var fujians = [];
var Fileid = 0;
var queudid = "";
var Openfujian = 0;

File Selection window Shutdown event handling
If a file is successfully selected and added to the upload queue, it is automatically uploaded
function Filedialogcomplete (Selectednum, Queuednum) {
if (Queuednum > 0) {//selected and added to the upload queue the number of files is greater than 0
Openfujian = Queuednum;
This.startupload ()/Start uploading
This.setbuttondisabled (TRUE);//Disable upload button
OpenDialog (' <div id= "Fujianbox" style= "overflow-y: scroll;height:180px;" ></div> ', ' Upload progress ', 285, 225);
}
}
Upload Process Event Handling
Use to dynamically display file upload progress
function uploadprogress (file, Curbytes, totalbytes) {
var f = file;
var c = curbytes;
var t = totalbytes;
var w = 235 * (curbytes/totalbytes);
if ($ ("#fujianbox")) {
if (Queudid!= f.id) {
Queudid = f.id;
Operation
} else {
$ ("#queudid" + f.id). CSS ("width", W + "px");
$ ("#baifenbi" + f.id). HTML ("(" + (parseint (curbytes/totalbytes) * 100) + "%") + ")";
}
}
}
Error during upload
function Uploaderror (file, Errcode, msg) {
openfujian--;
}
Upload successful
function uploadsuccess (file, data) {
var name = File.name;
var size = file.size;
var type = File.type;
var id = file.id;
var filestatus = File.filestatus;
var dataid = data;
if (Fileid = = 0) {
$ ("#bbsfiles"). Append ("uploaded attachment:");
}
if (name.length <= 18) {
Name = NAME.SUBSTR (0, 18);
} else {
Name = NAME.SUBSTR (0, 15) + ' ... ';
}
if (Size > 1024 * 1024) {
Size = ((size/1024/1024). toFixed (2))) + ' MB ';
} else {
Size = (Math.Round (size/1024)) + ' KB ';
}
Operation

fileid++;

alert (file,data);
}
Upload completed, regardless of the upload process error or upload success, will trigger the event, and after those two events are triggered
function Uploadcomplete (file) {
openfujian--;
if (Openfujian <= 0) {
This.setbuttondisabled (false);//Restore Upload button
Hidediv (' Messagebox_win ');
}
This.startupload ()/Start uploading
}
function Canceluploads (ID) {
Aswfu.cancelupload (ID);
}
var aswfuoption = {//swfupload option
Upload_url: "http://www.huhangfei.com.cn/bbsupload/fileupasp2015.asp?CookieID= @CookieID &swfupuser= @userinfo. UserName ",//receiving the uploaded server URL
Flash_url: "http://bbs.huhangfei.com.cn/images/swfupload2015215.swf",//swfupload the URL of the compressed package after decompression swfupload.swf
BUTTON_PLACEHOLDER_ID: "FL",//ID of the upload button placeholder
File_size_limit: "20MB",//user can choose the file size, valid units have B, KB, MB, GB, if no units default to KB
Prevent_swf_caching:false,
button_width:89,//button width
BUTTON_HEIGHT:34,//button height
Button_text: ',//button text
Button_text_style: ',//button text style
button_text_top_padding:6,//the top of the text distance button
button_text_left_padding:65,//text Distance button left distance
Button_image_url: "",//"http://simg.huhangfei.com.cn/bbs/revision/images/fj.jpg",//button background
Button_window_mode:SWFUpload.WINDOW_MODE. Transparent,
debug:true,//Open Debug Mode
file_dialog_complete_handler:filedialogcomplete,//File Selection dialog box close
upload_progress_handler:uploadprogress,//files on crosses
Error on upload_error_handler:uploaderror,//file
upload_success_handler:uploadsuccess,//file uploaded successfully
upload_complete_handler:uploadcomplete,//file upload completed, triggered after Upload_error_handler or Upload_success_handler
This place has a bug on windows, the official says: Under the window platform, the server-side handler must return a Non-null value after processing the file store, otherwise this event will not be triggered, and subsequent uploadcomplete events will not be able to execute.
Post_params: {"Cookieid": "@CookieID", "Swfupuser": "@userinfo." UserName "},
File_Types: "*.DOC;*.DOCX;*.TXT;*.ZIP;*.RAR;*.CAJ;*.PDF;*.VIP;",
file_types_description: [' Doc ', ' docx ', ' txt ', ' zip ', ' rar ', ' CAJ ', ' pdf ', ' VIP '] '
}
var aswfu = new SWFUpload (aswfuoption);
function Deletefujian (ID) {
$ ("#fujian" + ID). Remove ();
Bbspost.deletefujian (ID);
fileid--;
if (Fileid = = 0) {
$ ("#bbsfiles"). HTML ("");
}
}
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.