/*
Version history
1.0.2 - row 86 - added "escape" to the querystring to keep all the parameters intact
*/
function SWFUpload(settings) {
// Remove background flicker in IE
try
{
document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}
// Generate the tags ID
this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
// Load the settings. Load the Flash movie.
this.init(settings);
//fix ie refresh bugs
//this.loadFlash();
if (this.debug)
this.debugSettings();
}
SWFUpload.movieCount = 0;
// Default error handling.
SWFUpload.handleErrors = function(errcode, file, msg) {
switch(errcode) {
case -10: // HTTP error
alert("Error Code: HTTP Error, File name: " + file.name + ", Message: " + msg);
break;
case -20: // No upload script specified
alert("Error Code: No upload script, File name: " + file.name + ", Message: " + msg);
break;
case -30: // IOError
alert("Error Code: IO Error, File name: " + file.name + ", Message: " + msg);
break;
case -40: // Security error
alert("Error Code: Security Error, File name: " + file.name + ", Message: " + msg);
break;
case -50: // Filesize too big
alert(file.name+"文件大小受限制, 文件大小: " + file.size +"bit");
break;
}
};
SWFUpload.prototype.init = function(settings) {
this.settings = [];
this.addSetting("debug", settings["debug"], false); // Turn debugging on/off
// UI settings
this.addSetting("target", settings["target"], ""); // Target for auto-generated upload/browse links
this.addSetting("create_ui", settings["create_ui"], false); // Auto-generate UI
//this.addSetting("browse_link_class", settings["browse_link_class"], "SWFBrowseLink"); // CSS-class given to auto-generated browse link
//this.addSetting("upload_link_class", settings["upload_link_class"], "SWFUploadLink"); // CSS-class given to auto-generated upload link
this.addSetting("browse_link_ID", settings["browse_link_ID"], "<span>Browse...</span>"); // innerHTML for generated browse link, default surround with span for easy css-styling
this.addSetting("upload_link_ID", settings["upload_link_ID"], "<span>Upload</span>"); // innerHTML for generated upload link, default surround with span for easy css-styling
// Callbacks
this.addSetting("flash_loaded_callback", settings["flash_loaded_callback"], "SWFUpload.flashLoaded"); // Invoked when the flash is loaded
this.addSetting("upload_file_queued_callback", settings["upload_file_queued_callback"], ""); // Invoked when each file is added to the queue
this.addSetting("upload_file_start_callback", settings["upload_file_start_callback"], ""); // Invoked when upload starts
this.addSetting("upload_file_complete_callback", settings["upload_file_complete_callback"], ""); // Invoked when each file is completed
this.addSetting("upload_queue_complete_callback", settings["upload_queue_complete_callback"], ""); // Invoked when upload queue is complete
this.addSetting("upload_progress_callback", settings["upload_progress_callback"], ""); // Called with regular updates on progress..
this.addSetting("upload_dialog_cancel_callback", settings["upload_dialog_cancel_callback"], ""); // Invoked when cancel btn in dialog is clicked
this.addSetting("upload_file_error_callback", settings["upload_file_error_callback"], "SWFUpload.handleErrors"); // Invoked on error
this.addSetting("upload_file_cancel_callback", settings["upload_file_cancel_callback"], ""); // Invoked when a file upload is cancelled
this.addSetting("upload_queue_cancel_callback", settings["upload_queue_cancel_callback"], ""); // Invoked when upload queue is cancelled
// SWF Settings
this.addSetting("upload_script", escape(settings["upload_script"], "")); // The file that recieves the uploaded files from flash
this.addSetting("auto_upload", settings["auto_upload"], false); // Start upload directly or require upload button.
this.addSetting("allowed_filetypes", settings["allowed_filetypes"], "*.*"); // List of allowed filetypes
this.addSetting("allowed_filetypes_description", settings["allowed_filetypes_description"], "All files"); // Description for allowed filetypes
this.addSetting("allowed_filesize", settings["allowed_filesize"], 1024); // Max allowed filesize
this.addSetting("flash_path", settings["flash_path"], "jscripts/SWFUpload/SWFUpload.swf"); // Path to flash-file
this.addSetting("flash_target", settings["flash_target"], ""); // Where to output the flash (not used)
this.addSetting("flash_width", settings["flash_width"], "1px"); // Flash width
this.addSetting("flash_height", settings["flash_height"], "1px"); // Flash height
this.addSetting("flash_color", settings["flash_color"], "#000000"); // Flash color
this.debug = this.getSetting("debug"); // Set debug
};
SWFUpload.prototype.loadFlash = function() {
var html = "";
var sb = new stringBuilder();
// Create Mozilla Embed HTML
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
// Build the basic embed html
sb.append('<embed type="application/x-shockwave-flash" src="' + this.getSetting("flash_path") + '" width="' + this.getSetting("flash_width") + '" height="' + this.getSetting("flash_height") + '"');
sb.append(' id="' + this.movieName + '" name="' + this.movieName + '" ');
sb.append('bgcolor="' + this.getSetting["flash_color"] + '" quality="high" wmode="transparent" menu="false" flashvars="');
sb.append(this._getFlashVars());
sb.append('" />');
// Create IE Object HTML
} else {
// Build the basic Object tag
sb.append('<object id="' + this.movieName + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.getSetting("flash_width") + '" height="' + this.getSetting("flash_height") + '">');
sb.append('<param name="movie" value="' + this.getSetting("flash_path") + '" />');
sb.append('<param name="bgcolor" value="#000000" />');
sb.append('<param name="quality" value="high" />');
sb.append('<param name="wmode" value="transparent" />');
sb.append('<param name="menu" value="false" />');
sb.append('<param name="flashvars" value="' + this._getFlashVars() + '" />');
sb.append('</object>');
}
// Build the DOM nodes to hold the flash;
var container = document.createElement("div");
container.style.width = "0px";
container.style.height = "0px";
container.style.position = "absolute";
container.style.top = "0px";
container.style.left = "0px";
var target_element = document.getElementsByTagName("body")[0];
if (typeof(target_element) == "undefined" || target_element == null)
return false;
var html = sb.toString();
target_element.appendChild(container);
container.innerHTML = html;
this.movieElement = document.getElementById(this.movieName);
};
SWFUpload.prototype._getFlashVars = function() {
var sb = new stringBuilder();
sb.append("uploadScript=" + this.getSetting("upload_script"));
sb.append("&allowedFiletypesDescription=" + this.getSetting("allowed_filetypes_description"))
sb.append("&flashLoadedCallback=" + this.getSetting("flash_loaded_callback"));
sb.append("&uploadFileQueuedCallback=" + this.getSetting("upload_file_queued_callback"));
sb.append("&uploadFileStartCallback=" + this.getSetting("upload_file_start_callback"));
sb.append("&uploadProgressCallback=" + this.getSetting("upload_progress_callback"));
sb.append("&uploadFileCompleteCallback=" + this.getSetting("upload_file_complete_callback"));
sb.append("&uploadQueueCompleteCallback=" + this.getSetting("upload_queue_complete_callback"));
sb.append("&uploadDialo
SWFupload
4星 · 超过85%的资源 需积分: 9 43 浏览量
2008-08-25
15:13:16
上传
评论
收藏 9KB RAR 举报
guying1028
- 粉丝: 45
- 资源: 15
最新资源
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页