


Research on the Input button function of JavaScript type File_Form special effects
May 16, 2016 pm 07:00 PMFor 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
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 <input type="File"> 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
[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
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>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Hongmeng native application random poetry

How to implement an online speech recognition system using WebSocket and JavaScript

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems

How to implement an online reservation system using WebSocket and JavaScript

How to use JavaScript and WebSocket to implement a real-time online ordering system

JavaScript and WebSocket: Building an efficient real-time weather forecasting system

Simple JavaScript Tutorial: How to Get HTTP Status Code

How to use insertBefore in javascript
