uploadify多圖片上傳執行個體

來源:互聯網
上載者:User

標籤:

upload.php

  <html>      <head>        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">        <title>uploadify 多檔案上傳例子</title>        <link rel="stylesheet" type="text/css" href="uploadify/uploadify.css">      <script type="text/javascript" src="http://www.phpernote.com/js/jquery.min.js"></script>      <script type="text/javascript" src="uploadify/jquery.uploadify.js"></script>      <style type="text/css">        body {          font: 13px Arial, Helvetica, Sans-serif;        }        .haha{          color:#FFFFFF;        }        #queue {          background-color: #FFF;          border-radius: 3px;          box-shadow: 0 1px 3px rgba(0,0,0,0.25);          height: 103px;          margin-bottom: 10px;          overflow: auto;          padding: 5px 10px;          width: 300px;        }        </style>      </head>      <body>        <h1>Uploadify Demo</h1>        <form>          <div id="queue"></div>          <input id="file_upload" name="file_upload" type="file" multiple="true">        </form>        <script type="text/javascript">        $(function() {          $(‘#file_upload‘).uploadify({                      ‘debug‘         : false,                      ‘auto‘          : false,             //是否自動上傳,                      ‘buttonClass‘   : ‘haha‘,           //按鈕輔助class                      ‘buttonText‘    : ‘上傳圖片‘,       //按鈕文字                      ‘height‘        : 30,               //按鈕高度                      ‘width‘         : 100,              //按鈕寬度                                          ‘fileObjName‘   : ‘filedata‘,           //預設 Filedata, $_FILES控制項名稱                      ‘fileSizeLimit‘ : ‘1024KB‘,          //檔案大小限制 0為無限制 預設KB                      ‘fileTypeDesc‘  : ‘All Files‘,       //圖片選擇描述                      ‘fileTypeExts‘  : ‘*.gif; *.jpg; *.png‘,//檔案尾碼限制 預設:‘*.*‘                      ‘formData‘      : {‘someKey‘ : ‘someValue‘, ‘someOtherKey‘ : 1},//傳輸資料JSON格式                      //‘overrideEvents‘: [‘onUploadProgress‘],  // The progress will not be updated                      //‘progressData‘ : ‘speed‘,             //預設percentage 進度顯示方式                      ‘queueID‘       : ‘queue‘,              //預設隊列ID                      ‘queueSizeLimit‘: 20,                   //一個隊列上傳檔案數限制                      ‘removeCompleted‘ : true,               //完成時是否清除隊列 預設true                      ‘removeTimeout‘   : 3,                  //完成時清除隊列顯示秒數,預設3秒                      ‘requeueErrors‘   : false,              //隊列上傳出錯,是否繼續復原隊列                      ‘successTimeout‘  : 5,                  //上傳逾時                      ‘uploadLimit‘     : 99,                 //允許上傳的最多張數                      ‘swf‘  : ‘uploadify/uploadify.swf‘, //swfUpload                      ‘uploader‘: ‘handle.php‘, //伺服器端指令碼                      //修改formData資料                      ‘onUploadStart‘ : function(file) {                          $("#file_upload").uploadify("settings", "someOtherKey", 2);                        },                      //刪除時觸發                      ‘onCancel‘ : function(file) {                          // alert(‘The file ‘ + file.name + ‘--‘ + file.size + ‘ was cancelled.‘);                        },                      //清除隊列                      ‘onClearQueue‘ : function(queueItemCount) {                          // alert(queueItemCount + ‘ file(s) were removed from the queue‘);                        },                      //調用destroy是觸發                      ‘onDestroy‘ : function() {                        alert(‘我被銷毀了‘);                      },                      //每次初始化一個隊列是觸發                      ‘onInit‘ : function(instance){                          // alert(‘The queue ID is ‘ + instance.settings.queueID);                        },                      //上傳成功                      ‘onUploadSuccess‘ : function(file, data, response) {                          alert(file.name + ‘ | ‘ + response + ‘:‘ + data);                        $(‘#error‘).html(data)                      },                      //上傳錯誤                      ‘onUploadError‘ : function(file, errorCode, errorMsg, errorString) {                          alert(‘The file ‘ + file.name + ‘ could not be uploaded: ‘ + errorString);                        },                      //上傳匯總                      ‘onUploadProgress‘ : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {                        $(‘#progress‘).html(totalBytesUploaded + ‘ bytes uploaded of ‘ + totalBytesTotal + ‘ bytes.‘);                      },                      //上傳完成                      ‘onUploadComplete‘ : function(file) {                          // alert(‘The file ‘ + file.name + ‘ finished processing.‘);                        },                      });    });              //變換按鈕              function changeBtnText() {                $(‘#file_upload‘).uploadify(‘settings‘,‘buttonText‘,‘繼續上傳‘);              }              //返回按鈕              function returnBtnText() {                alert(‘The button says ‘ + $(‘#file_upload‘).uploadify(‘settings‘,‘buttonText‘));              }              </script>              <h4>操作:</h4>               <a href="javascript:$(‘#file_upload‘).uploadify(‘upload‘, ‘*‘);">開始上傳</a>  |               <a href="javascript:$(‘#file_upload‘).uploadify(‘cancel‘, ‘*‘);">清除隊列</a>  |               <a href="javascript:$(‘#file_upload‘).uploadify(‘destroy‘);">銷毀上傳</a>  |               <a href="javascript:$(‘#file_upload‘).uploadify(‘disable‘, true);">禁用上傳</a>  |               <a href="javascript:$(‘#file_upload‘).uploadify(‘disable‘, false);">啟用上傳</a>  |               <a href="javascript:$(‘#file_upload‘).uploadify(‘stop‘);">停止上傳</a>  |               <a href="javascript:changeBtnText();">變換按鈕</a>  |               <h4>大小:</h4>              <div id=‘progress‘></div>              <h4>錯誤提示:</h4>             <div id=‘error‘></div>            </body>   </html>  

handle.php

<?phpif(@$_FILES["filedata"]){    $path="upload/" . $_FILES["filedata"]["name"];//把上傳的檔案移動到指定目錄    move_uploaded_file($_FILES["filedata"]["tmp_name"],$path);}?>

效果:

 

uploadify多圖片上傳執行個體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.