JavaScript type file Input button function Research _ form Effects

Source: Internet
Author: User
Like http://www.youku.com/v1.0.0326/v/swf/up.swf.
This is a cool video upload selection, it is through the Flash method to achieve the display of non-video class files.
Flash to this effect is generally as described here
Copy Code code as follows:

Import flash.net.FileReferenceList;
var fileref:filereferencelist = new Filereferencelist ();
var alltypes:array = [];
var browse type: Object = new Object ();
Browse type. Description = "Browse type (*.mp3)";
Browse type. Extension = "*.mp3";
Alltypes.push (browse type);
Fileref.browse (alltypes);

So is <input type= "file" > can also implement pop-up-restricted file types for our web pages?
Now the solution can only be monitored to remind the user that the upload file is not in the correct format
<script> function Check () {var filepath=path.value filepath=filepath.substring filepath.lastindexof ('. ') +1,filepath.length) if (filepath!= ' jpg ' && filepath!= ' gif ') alert ("Upload only pictures in jpg or GIF format")} </script> &L T;input type=file name=path onpropertychange= "check ()" > (only images in JPG or GIF format can be uploaded)
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

<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 (). ExecCommand (' delete ')}; } </script> <form> <input type=file name=path onpropertychange= "ck (this)"/></form>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

But the 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.