1. 程式人生 > >頭像截圖上傳兩種方式(SWFUpload、一個簡單易用的flash外掛)

頭像截圖上傳兩種方式(SWFUpload、一個簡單易用的flash外掛)

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title></title> 5 <script src="../JS/handlers.js" type="text/javascript"></script> 6 <script src="
../JS/jquery-1.8.2.js" type="text/javascript"></script> 7 <script src="../JS/swfupload.js" type="text/javascript"></script> 8 <script type="text/javascript"> 9 var swfu; 10 window.onload = function () { 11 swfu = new SWFUpload({ 12 //
Backend Settings 13 //修改執行上傳操作的檔案(aspx或ashx) 14 upload_url: "UploadImg.ashx", 15 post_params: { 16 "ASPSESSID": "<%=Session.SessionID %>" 17 }, 18 19 // File Upload Settings 20 file_size_limit: "
2 MB", 21 file_types: "*.jpg", 22 file_types_description: "JPG Images", 23 file_upload_limit: 0, // Zero means unlimited 24 25 // Event Handler Settings - these functions as defined in Handlers.js 26 // The handlers are not part of SWFUpload but are part of my website and control how 27 // my website reacts to the SWFUpload events. 28 swfupload_preload_handler: preLoad, 29 swfupload_load_failed_handler: loadFailed, 30 file_queue_error_handler: fileQueueError, 31 file_dialog_complete_handler: fileDialogComplete, 32 upload_progress_handler: uploadProgress, 33 upload_error_handler: uploadError, 34 //指定圖片上傳成功後執行的方法為我們自己定義的ShowData 35 upload_success_handler: ShowData, 36 upload_complete_handler: uploadComplete, 37 38 // Button settings 39 button_image_url: "images/XPButtonNoText_160x22.png", 40 button_placeholder_id: "spanButtonPlaceholder", 41 button_width: 160, 42 button_height: 22, 43 button_text: '<span class="button">Select Images <span class="buttonSmall">(2 MB Max)</span></span>', 44 button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }', 45 button_text_top_padding: 1, 46 button_text_left_padding: 5, 47 48 // Flash Settings 49 //在這裡修改flash外掛的引用路徑 50 flash_url: "/Flash/swfupload.swf", // Relative to this file 51 flash9_url: "/Flash/swfupload_FP9.swf", // Relative to this file 52 53 custom_settings: { 54 upload_target: "divFileProgressContainer" 55 }, 56 57 // Debug Settings 58 debug: false 59 }); 60 } 61 //上傳成功後執行,將img標籤的src設定為返回的圖片儲存好的路徑 62 function ShowData(file, serverData) { 63 $("#imgSrc").attr("src", serverData); 64 }; 65 </script> 66 67 68 </head> 69 <body> 70 <form> 71 <div id="content"> 72 <div id="swfu_container" style="margin: 0px 10px;"> 73 <div> 74 <span id="spanButtonPlaceholder"></span> 75 </div> 76 <div id="divFileProgressContainer" style="height: 75px;"></div> 77 <div id="thumbnails"></div> 78 </div> 79 </div> 80 <img id="imgSrc" /> 81 82 </form> 83 84 </body> 85 </html>