JS開啟選擇本地檔案的對話方塊

來源:互聯網
上載者:User

標籤:style   java   檔案   width   for   re   

方法一:

在定義的form中添加以下javascript代碼:

    {
             anchor : ‘95%‘,
             xtype: ‘fileuploadfield‘,
             id: ‘form-file‘,
             emptyText: ‘請選擇‘,
             fieldLabel: ‘上傳附件‘,
             name: ‘meetingAffix‘,
             buttonText: ‘Browse‘
    }

單擊Browse按鈕後可以開啟對話方塊,選中檔案後,所選檔案路徑會出現在上傳附件後面的文字框中。

 

方法二:

在定義的form中添加以下javascript代碼:

{
      columnWidth :1,
      layout :‘form‘,
      bodyStyle :‘padding:10px‘,
      defaultType :‘textfield‘,
      labelWidth :120,
      width :1000,
      buttonAlign :‘center‘,
      items : [ {
       fieldLabel :‘請選擇要上傳的檔案‘,
       name :‘fileName‘,
       id :‘fileId‘,
       anchor :‘95%‘,
      allowBlank :false,
       inputType :‘file‘
      } ]
}

 

方法三:

給按鈕定義以下javascript函數:

        var inputObj=document.createElement(‘input‘)
        inputObj.setAttribute(‘id‘,‘_ef‘);
        inputObj.setAttribute(‘type‘,‘file‘);
        inputObj.setAttribute("style",‘visibility:hidden‘);
        document.body.appendChild(inputObj);
        inputObj.click();
        inputObj.value ;

單擊已經添加函數的按鈕會彈出選擇本地檔案的對話方塊。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.