Discover html5 file upload example, include the articles, news, trends, analysis and practical advice about html5 file upload example on alibabacloud.com
No-refresh file upload is a common and somewhat complex problem, and the common solution is to construct an IFRAME implementation.
A FormData object API is provided in HTML5, which makes it easy to construct a form request and send it through XMLHttpRequest. It is also possible to send files through the FormData object, so it is very easy to
First, let's introduce the multiple property of file in HTML5
Definitions and usage
The multiple property stipulates that the input field can select multiple values. If this property is used, the field can accept multiple values.
Instance:
The input file in the above instance can accept multiple file
Cjhupload: A simple asynchronous file upload plug-in (html5 + js ),
Source: http://www.myopenresources.com/page/resource_detail_0.html? Rid = 370
For more information, see my blog website: http://www.myopenresources.com
Cjhupload is a file upload plug-in compiled by myself
In the last article to introduce you to this article inside the background servlet. So here only look at the front desk JS code.
First HTML5 to use AJAX to submit data first to learn a HTML5 new object: FormData
The FormData object can be added using the Append method for Key-value data, unlike the JSON we used to use to upload binary files asynchronously.
1,
First, let me introduce you to the multiple property of file in HTML5
Definition and usage
The Multiple property specifies that the input field can select multiple values. If you use this property, the field can accept multiple values.
Instance:
The input file in the above instance can accept multiple upload fie
(value); }
1
2
3
Results:8, Entries ()There is an iterator that iterates through a key, and an iterator that iterates over the value, why not make a combination of the two? Entries () is the return of an iterator containing a key-value pair:for(var pair of fd.entries()) { console.log(pair[0]+ ‘, ‘+ pair[1]); }
1
2
3
Results:formdata compatibility issuesBecause FormData is the XMLHttpRequest Level 2 new interface, now less than IE10 IE browser
Comments: HTML 5 is a powerful tool for Web developers. Recently, W3C has released a new draft-HTML5 File API, which will greatly improve Web-based File upload operations and even directly drag and drop files from the desktop to the Web.HTML 5It makes HTML, a simple slogan, a mature charm, a powerful tool for Web devel
in the format of $ handle-> image_y = [value]. here, the program is told to scale proportionally based on the width.$ Handle-> process ('/home/user/files/'); // you can set more processing options before executing this sentence, for example, if you want to rotate and crop the image, you can use this sentence to process and upload the image. During image processing, a copy of the original image will be crea
This article illustrates the Ajax upload file and progress bar implementation methods, share for everyone to reference, the specific content as follows
Effect Chart:
HTML5 upload is the way of synchronous upload, so can achieve the display of progress bar.1.
Copy Code code as follows:
That's what we can do in the ASP.net MVC Web application:
Copy Code code as follows:
@using (Html.BeginForm ("Upload", "Home", FormMethod.Post, new {enctype = "multipart/form-data", id = "Form2"}))
{
}
Suppose this is a homecontroller view that is about to be submitted to the upload action, looking at the following server-side code:
This is a creation in
Article, where the information may have evolved or changed.
Golang Write service-side program, as a file upload and download server. Cooperate with HTML5 to use Web page as user page
1. Entire Engineering structure
Where: Mainup.go is listening to the local waiting for user access to upload the s
This is a creation in
Article, where the information may have evolved or changed.
Golang Write service-side program, as a file upload and download server. Cooperate with HTML5 to use Web page as user page
1. Entire Engineering structure
Where: Mainup.go is listening to the local waiting for user access to upload the s
Interface style I was referring to a foreign album website, change is not big, just convert the birds into Chinese, and upload the style also made changes, the reason for this choice is that I am easy to do extension, it supports 3 ways to add pictures, a drag and drop upload, a general selection file upload, The other
Use Input[type=file] to upload files in Html4, but also in HTML5, but much richer than HTML4.
Such as:
Added the Multiple property, plus you can upload multiple files at the same time.
You'll notice that there are so many things printed in the console:
Yes, this is the
Source: http://www.myopenresources.com/page/resource_detail_0.html?rid=370More articles please view my blog website: http://www.myopenresources.comCjhupload is a I write based on native JS file upload plugin, support mobile phone, computer side, you can view examples, or download detailed examples (please go to the "" download below).Example:SubmitEffect: Cjhupload A simple asynchronous
Uploading Video IdeasHtml:1. HTML5 tag video audio/video is used here first2. INPUT type = FileCSS gives some styleJsJS Implementation ideas:1. Obtain the upload file (input) label and give it a variable by using the native method.2. Get the audio tag from the native method and give it to a variable.3. By using the input tag to get its own files[0], and we need t
Java Web image upload and file upload
Picture uploads and file uploads are essentially the same, and the picture itself is a file. File upload is the picture uploaded to the server, al
The example of this article tells the package thinkphp a file upload method, share for everyone for reference. Specifically as follows:
Over the wblog, the upload function has been optimized. After the improved upload function can achieve thumbnail
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.