Home Web Front-end JS Tutorial Research on the Input button function of JavaScript type File_Form special effects

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

May 16, 2016 pm 07:00 PM
file input javascript

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 <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
(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>
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hongmeng native application random poetry Hongmeng native application random poetry Feb 19, 2024 pm 01:36 PM

Hongmeng native application random poetry

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

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

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

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

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

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 How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

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 JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

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

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

Simple JavaScript Tutorial: How to Get HTTP Status Code

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

How to use insertBefore in javascript

See all articles