2013-10-23 45 views
1

我想aplly在ExtJS的上傳文件如本例:文件上傳ExtJS的

myuploadform= new Ext.FormPanel({ 
      fileUpload: true, 
      width: 500, 
      autoHeight: true, 
      bodyStyle: 'padding: 10px 10px 10px 10px;', 
      labelWidth: 50, 
      defaults: { 
       anchor: '95%', 
       allowBlank: false, 
       msgTarget: 'side' 
      }, 
      items:[ 
      { 
       xtype: 'fileuploadfield', 
       id: 'filedata', 
       emptyText: 'Select a document to upload...', 
       fieldLabel: 'File', 
       buttonText: 'Browse' 
      }], 
      buttons: [{ 
       text: 'Upload', 
       handler: function(){ 
        if(myuploadform.getForm().isValid()){ 
         form_action=1; 
         myuploadform.getForm().submit({ 
          url: 'handleupload.php', 
          waitMsg: 'Uploading file...', 
          success: function(form,action){ 
           msg('Success', 'Processed file on the server'); 
          } 
         }); 
        } 
       } 
      }] 
     }) 

當我運行它,我看到它試圖要上傳的文件並沒有什麼happends(它永遠不會完成);

現在我明白handleupload.php應該處理上傳的文件。

我已經tryed aplying它在這個eaxmple:file upload using EXT JS

,但我似乎無法使其工作,應該是究竟是什麼在PHP文件?

TY。

回答

0

有一個在上載有PHP後臺文件(包括PHP代碼)的SDK下載一個例子。查看/examples/form/file-upload.html。

這應該有你需要的一切。

+0

找不到php部分。這是我唯一缺少的部分,你可以請複製PHP服務器端的代碼 – susparsy

+0

它被稱爲'file-upload.php'。 –

+0

我創建了從示例代碼中的handleupload.php,並在控制檯中我得到:「未捕獲Ext.JSON.decode():你試圖解碼的JSON字符串無效:......」 – susparsy