JS Open the dialog box to select Local files

Source: Internet
Author: User

Method One:

Add the following JavaScript code to the defined form:

{
Anchor: ' 95% ',
Xtype: ' Fileuploadfield ',
ID: ' Form-file ',
Emptytext: ' Please select ',
Fieldlabel: ' Upload attachments ',
Name: ' Meetingaffix ',
ButtonText: ' Browse '
}

After you click the browse button, you can open the dialog box, and when the file is selected, the selected file path appears in the text box after the upload attachment.

Method Two:

Add the following JavaScript code to the defined form:

{
Columnwidth:1,
Layout: ' Form ',
Bodystyle: ' padding:10px ',
DefaultType: ' TextField ',
LABELWIDTH:120,
width:1000,
Buttonalign: ' Center ',
Items: [{
Fieldlabel: ' Please select the file to upload ',
Name: ' FileName ',
ID: ' FileId ',
Anchor: ' 95% ',
Allowblank:false,
InputType: ' File '
} ]
}

Method Three:

Define the following JavaScript functions for the button:

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;

Clicking the button that has added a function pops up a dialog box that selects the local file.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.