Research on the Input button function of javascript-type File _ form special effects

Source: Internet
Author: User
When you upload a file to a website, the Select File Dialog Box is displayed when you click the Browse button. Most of the time, we only need to upload image files. In the pop-up "select file" dialog box, only related image format files are displayed. In addition, all other format files are filtered and not displayed. Like http://www.youku.com/v1.0.0326/v/swf/up.swf
This is Youku's video upload option. It does not display non-video files through FLASH.
The FLASH effect is generally described here.

The Code is as follows:


Import flash.net. FileReferenceList;
Var fileRef: FileReferenceList = new FileReferenceList ();
Var allTypes: Array = [];
Var browsing type: Object = new Object ();
Browsing type. description = "browsing type (*. mp3 )";
Browsing type. extension = "*. mp3 ";
AllTypes. push (browsing type );
FileRef. browse (allTypes );


Therefore Can I limit the file type in the pop-up window as well?
The solution is to use monitoring to remind users that the format of uploaded files is incorrect.

Script function check () {var filepath = path. value filepath = filepath. substring (filepath. lastIndexOf ('.') + 1, filepath. length) if (filepath! = 'Jpg '& filepath! = 'Gif') alert ("only images in JPG or gif format can be uploaded")} script <input type = file name = path onpropertychange = "check () "> (only JPG or GIF images can be uploaded)
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]


Script function ck (obj) {if (obj. value. length> 0) {var af = "jpg, gif, png, zip, rar, txt, htm"; if (eval ("with (obj. value) if (! /"+ Af. split (","). join ("|") + "/ig. test (substring (lastIndexOf ('. ') + 1, length) 1; ") {alert (" Allowed file types: \ n "?af==obj.createtextrange(cmd.exe cCommand ('delete') }}} script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]


However, this effect is obviously not as good as the FLASH user experience. It is necessary to pay attention to this type of FLASH upload.
Related Article

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.