Home > Web Front-end > JS Tutorial > body text

Research on the Input button function of JavaScript type File_Form special effects

WBOY
Release: 2016-05-16 19:00:11
Original
1378 people have browsed it

For example, http://www.youku.com/v1.0.0326/v/swf/up.swf
This is Youku’s video upload option, which uses FLASH to prevent non-video files from being displayed.
FLASH to this effect is generally as described here

Copy code The code is 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 for the in our webpage, can we also implement pop-up windows to limit file types?
The current solution can only be to remind users that the format of the uploaded file is incorrect through monitoring
(Only images in JPG or GIF format can be uploaded)
[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
<script> function check(){ var filepath=path.value filepath=filepath.substring(filepath.lastIndexOf('.')+1,filepath.length) if(filepath != 'jpg' && filepath != 'gif') alert("只能上传JPG或GIF格式的图片") } </script>However, this effect obviously does not FLASH has a good user experience. It is necessary to pay attention to this type of FLASH upload. <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>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!