swfupload上傳組件

var upload1, upload2,uoload3;

		window.onload = function() {
			upload1 = new SWFUpload({
				// Backend Settings
				upload_url: "<?php echo base_url().'index.php?c=user_upload&m=upload_apk'; ?>",	
				post_params: {"uniqid" : "<?php echo $uniqid;?>",
					"PHPSESSID":"<?php echo session_id() ?>"
					},
				

				// File Upload Settings
				file_size_limit : "1024000",	// 100MB
				file_types : "*.apk;*.flv*.AVI;*.WMV;*.MOV;*.DAT;*.RMVB;*.MP4;*.3GP;*.RMVB;*.MP3;*.WMA;*.WAV;*.OGG;",
				file_types_description : "All Files",
				file_upload_limit : 100,
				file_queue_limit : 1,

				// Event Handler Settings (all my handlers are in the Handler.js file)
				swfupload_preload_handler : preLoad,
				swfupload_load_failed_handler : loadFailed,
				file_dialog_start_handler : fileDialogStart,
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete,
				// Button Settings
				button_image_url : "images/XPButtonUploadText_61x22.png",
				button_placeholder_id : "spanButtonPlaceholder1",
				button_width: 61,
				button_height: 22,
				
				// Flash Settings
				flash_url : "swfupload/swfupload.swf",
				flash9_url : "swfupload/swfupload_fp9.swf",
			

				custom_settings : {
					progressTarget : "fsUploadProgress1",
					cancelButtonId : "btnCancel1"
				},
				
				// Debug Settings
				debug: false
			});

			upload2 = new SWFUpload({
				// Backend Settings
				upload_url: "<?php echo base_url().'index.php?c=user_upload&m=upload_icon'; ?>",	
				post_params: {"uniqid" : "<?php echo $uniqid;?>",
					"PHPSESSID":"<?php echo session_id() ?>"},


				// File Upload Settings
				file_size_limit : "1000",	// 1M
				file_types : "*.jpg;*.gif;*.png;",
				file_types_description : "Image Files",
				file_upload_limit : "100",
				file_queue_limit : "1",

				// Event Handler Settings (all my handlers are in the Handler.js file)
				swfupload_preload_handler : preLoad,
				swfupload_load_failed_handler : loadFailed,
				file_dialog_start_handler : fileDialogStart,
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete2,
				// Button Settings
				button_image_url : "images/XPButtonUploadText_61x22.png",
				button_placeholder_id : "spanButtonPlaceholder2",
				button_width: 61,
				button_height: 22,
				
				// Flash Settings
				flash_url : "swfupload/swfupload.swf",
				flash9_url : "swfupload/swfupload_fp9.swf",

				swfupload_element_id : "flashUI2",		// Setting from graceful degradation plugin
				degraded_element_id : "degradedUI2",	// Setting from graceful degradation plugin

				custom_settings : {
					progressTarget : "fsUploadProgress2",
					cancelButtonId : "btnCancel2"
				},

				// Debug Settings
				debug: false
			});



			upload3 = new SWFUpload({
				// Backend Settings
				upload_url: "<? echo base_url()."index.php?c=user_upload&m=upload_pictures"?>",
				post_params: {
				"uniqid" : "<?php echo $uniqid;?>",
				"PHPSESSID":"<?php echo session_id() ?>"},
				// File Upload Settings
				file_size_limit : "50000",	// 5M
				file_types : "*.jpg;*.gif;*.png;",
				file_types_description : "Image Files",
				file_upload_limit : "50",
				file_queue_limit : "5",

				// Event Handler Settings (all my handlers are in the Handler.js file)
				swfupload_preload_handler : preLoad,
				swfupload_load_failed_handler : loadFailed,
				file_dialog_start_handler : fileDialogStart,
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete3,				
				// Button Settings
				button_image_url : "images/XPButtonUploadText_61x22.png",
				button_placeholder_id : "spanButtonPlaceholder3",
				button_width: 61,
				button_height: 22,
				
				// Flash Settings
				flash_url : "swfupload/swfupload.swf",
				flash9_url : "swfupload/swfupload_fp9.swf",

				swfupload_element_id : "flashUI3",		// Setting from graceful degradation plugin
				degraded_element_id : "degradedUI3",	// Setting from graceful degradation plugin

				custom_settings : {
					progressTarget : "fsUploadProgress3",
					cancelButtonId : "btnCancel3"
				},

				// Debug Settings
				debug: false
			});

	     };

	     
	     function queueComplete(numFilesUploaded) {
		     $(".app").hide();
	    	 $("#divStatus").html("服務器正在識別文件!");
	    		 $.post(
	    			      "<?php echo base_url()."index.php?c=user_upload&m=get_info"?>",
	    			      {
	    			    	 unid:"<?php  echo $uniqid;?>"
	    			      },
	    			      function (data) //回傳函數
	    			      {
	    			        var myjson='';
	    			        eval('myjson=' + data + ';');
	    			      if(myjson['info']=="successopen"){
	    			    	  $(".app").show();
	    			    	    $("#versionName").val(myjson['versionName']);
		    			        $("#versionCode").val(myjson['versionCode']);
		    			        $("#package").val(myjson['package']);
		    			        $("#min_sdk").val(myjson['min_sdk']);
			    			    $("#size").val(myjson['filesize']);
			    			    $("#apkfilename").val(myjson['filename']);
		    		            $("#divStatus").html("文件上傳成功!");
		    			      }
	    			      if(myjson['info']=="errorfile"){
	    			    	      
		    			    	  $("#divStatus").html("解析文件失敗!");
		    			    	  alert("文件無法解析或被損壞!");
			    			      }
	    			      if(myjson['info']=="audiofile"){
	    			    	  $(".app").show();
	    			    	  $("#apkfilename").val(myjson['filename']);
	    			    	  $("#size").val(myjson['filesize']);
	    			    	  $("#divStatus").html("文件上傳成功!");
		    			      }

	    		            }
	    			      
	    				     );
	    				     
	    	}


	     function queueComplete2(numFilesUploaded) {

	    	 $.post(
   			      "<?php echo base_url().'index.php?c=user_upload&m=get_icon'?>",
   			      {
   			    	 unid:"<?php  echo $uniqid;?>"
   			      },
   			      function (data) //回傳函數
   			      {
   			        var myjson='';
   			        eval('myjson=' + data + ';');
   			     var iconname =myjson['filename'];
   			     var unid     =myjson['unid'];
   			     var icon ="";
   			     $("#icon").val(iconname);
   			     icon ="<img width='48' height='48' src='<?php echo "../file_temporary/".$uniqid."/app_icons/"?>"+"/"+iconname+"'>";
   			     $("#iconarea").html(icon);
   			       
   			      }
   				     );
	    				     
	    	}
	   

	     function queueComplete3(numFilesUploaded) {
	    	 $("#imgsView").html("");
	    	 $.post(
   			      "<?php echo base_url().'index.php?c=user_upload&m=get_pictures'?>",
   			      {
   			    	 unid:"<?php  echo $uniqid;?>"
   			      },
   			      function (data) //回傳函數
   			      {
   			        var myjson='';
   			        eval('myjson=' + data + ';');
   			     var pictures =myjson['filename'];
   			     var i=0;
   			     $("#app_pictures").val(pictures.length);
   			     for(i=0;i<pictures.length;i++){
   	   			    $("#imgsView").append("<img  src='<?php echo "../file_temporary/".$uniqid."/app_thumbs/";?>"+pictures[i]+"'><a href='javascript:void(0)' οnclick='del_pictures("+'"'+pictures[i]+'"'+")'>刪除</a>");
   	   			    
   	   			     };
   			 
   			      }
   				     );
	    				     
	    	}






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章