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.
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 we limit the File type in the pop-up window for our webpage <input type = "File">?
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 JPG or GIF images can be uploaded ")
}
</Script>
<Input type = file name = path onpropertychange = "check ()"> (only JPG or GIF images can be uploaded)
<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>
<Form>
<Input type = file name = path onpropertychange = "ck (this)"/> </form>
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.