最簡(jiǎn)化的上傳按鈕和表單
本上傳插件的特色:
1、支持大文件上傳,最大支持單個(gè)2G文件上傳,親測(cè)成功上傳一個(gè)677M的視頻文件到服務(wù)器,并且沒(méi)有超時(shí),
完整返回了視頻信息。上傳大文件并不占用服務(wù)器內(nèi)存,放心使用。
2、無(wú)刷新上傳顯示,帶進(jìn)度條功能。
3、支持跨服務(wù)器,跨域名上傳,可上傳到指定服務(wù)器,親測(cè)已成功無(wú)須顧慮。本功能可輕松實(shí)現(xiàn)網(wǎng)站和
附件服務(wù)器分離,減輕網(wǎng)站服務(wù)器的負(fù)擔(dān)。
4、安裝簡(jiǎn)單,只需把下面的代碼粘貼到需要上傳功能的頁(yè)面即可實(shí)現(xiàn)上傳功能。
//兩個(gè)js文件和風(fēng)格文件,必須的。
在需要顯示上傳的地方加入以下代碼
//上傳控制與顯示部分
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend Settings
upload_url: "upload.php", ?//upload.php文件的位置,可使用絕對(duì)路徑
post_params: {"PHPSESSID": ""},
?
// File Upload Settings
file_size_limit : "1000 MB", // 上傳文件控制大小
file_types : "*.wma;*.mp4;*.rmvb;*.mp3;*.wmv;*.flv;*.avi;*.3gp;*.mov", //上傳文件類型控制
file_types_description : "JPG Images",
file_upload_limit : "0",
?
// Event Handler Settings - these functions as defined in Handlers.js
// ?The handlers are not part of SWFUpload but are part of my website and control how
// ?my website reacts to the SWFUpload events.
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 Settings
button_image_url : "images/user-upload-upm.gif",
button_placeholder_id : "spanButtonPlaceholder",
button_width: 158,
button_height: 50,
button_text : '',
button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 0,
button_text_left_padding: 0,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
?
// Flash Settings
flash_url : "images/swfupload.swf", ? //swf文件位置
?
custom_settings : {
upload_target : "divFileProgressContainer"
},
?
// Debug Settings
debug: false
});
};
?
?
if( !function_exists("imagecopyresampled") ){
?>
} else {
?>
}
?>
//傳值部分,不能修改
function uploadSuccess(file,data,response ){
?
var data = data.split(';');?
//alert(data[1] + data[2] + data[3]+ data[4] +data[5]);
document.getElementById('cname').value= data[1];
?document.getElementById('path').value= data[2];
?document.getElementById('pic').value= data[3];
?document.getElementById('convertname').value= data[4];
?document.getElementById('name').value= data[5];
?
document.getElementById('odownpath1').value = data[2]+data[4];
document.getElementById('titlepic').value = data[2]+data[3];
document.getElementById('movietitle').value = data[6];
document.getElementById('moviesay').value = data[6];
}