Discover html5 drag and drop file upload example, include the articles, news, trends, analysis and practical advice about html5 drag and drop file upload example on alibabacloud.com
Today, there is a need, the page has a "Click Upload" button, click can perform upload events, drag and drop the image from the desktop to any place, can perform the upload, and does not affect the Click button event. Here is a simple example:A Simple
){// ObtainthereadfiledataVarfilestringincluevt.tar get. result;// HandleUTF-16filedumpIf (utils. regexp. isChinese (fileString )){// ChineseCharacters + Namevalidation}Else {// Runothercharsettest}// Xhr. send (fileString)}FunctionerrorHandler (evt ){If(evt.tar get. error. name = "NotReadableErr "){// Thefilecouldnotberead}}
The window. open method is used for normal file download. For example:
the file type that is allowed to be uploaded, in the form of a comma-delimited MIME type or extension. For example: Image/*,application/pdf,.psd,.obj
Uploadmultiple: Indicates whether to allow Dropzone to submit multiple files at once. The default is False. If set to True, the equivalent HTML form adds the multiple property.
Headers: If set, it will be sent to the server as additional header information.
Comments: Using HTML5 to drag files to a browser and upload and download files, html5 is becoming more and more powerful. I will share with you the specific implementation code below. If you are interested, please refer
First, the code is written on the jsp page, and the background is the tomcat server. Therefore, the
Local upload, preview in advance (picture. VideoThe div tag preview display in 1.html. The button tag triggers the upload event.2. Disable browser Open file behaviorDocument.addeventlistener ("Drop", function (e) { //Drag off E.preventdefault (); }) Document.addeventlist
In the article [file discussion-First knowledge of file control] (http://www.seejs.com/archives/668 "File discussion-the first knowledge of file control"), we have a preliminary understanding of the file control, And to make a detailed description of creating a visual and ex
Local upload, preview in advance (image, video)The div tag Preview in 1.html shows that the button tag triggers the upload event.2. Disable browser Open file behaviorDocument.addeventlistener ("Drop", function (e) { //Drag off E.preventdefault (); }) Document.addeventlis
Interface style I was referring to a foreign Photo album website, the change is not big, just to convert the birds into Chinese, as well as the upload style has also been changed, the reason for this is that I can easily do the extension, it supports 3 ways to add pictures, a drag-and-drop upload, a general choice of
here.
var box = This.box;
var tmpbody = this.tmpbody;
var cover = This.cover;
if (Tmpbody tmpbody[0]) {
$ (' body '). Append (Tmpbody);
}
if (box box[0]) {
Box.remove ();
}
if (cover cover[0]) {
Cover.hide ();
}
};
Call Method:
Copy Code code as follows:
var dia = new Mydialog ({
Title:title,
Bodyid:id,
Id:id + ' _box '
});
Dia.show ();
You may also need a certain function callback, you can encapsulate it yourself.
Share an excellent tutorial from tutorizine-create an Ajax-based File drag-and-drop Upload function, and use the jQuery File Upload plug-in and the jQuery Knob plug-in to implement a beautiful CSS3/JS-driven interface.Articles you
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
Originally prepared to write a support multi-image drag-and-drop upload example, but in order to better understand, first introduce the HTML5 drag and drop.Drag-and-drop (
Share an excellent tutorial from tutorizine-create an Ajax-based File drag-and-drop Upload function, and use the jQuery File Upload plug-in and the jQuery Knob plug-in to implement a beautiful CSS3/JS-driven interface.Articles you
With the popularity of HTML5 more and more high, now write code also encountered some, after colleagues on-demand to carry out a dojo activities for technical exchanges, I also take this opportunity to HTML5 drag and drop function to organize a bit.Brief introductionDrag-and-drop
(tmpBody tmpBody [0]) {$ ('Body'). append (tmpBody );}If (box box [0]) {Box. remove ();}If (cover cover [0]) {Cover. hide ();}};Call method:Copy codeThe Code is as follows:Var dia = new MyDialog ({Title: title,BodyId: id,Id: id + '_ box'});Dia. show ();Some Function callbacks may be required. You can encapsulate them yourself.
Drag and DropSome requirements for drag-and-
JQuery File Uploader is a jQuery File drag-and-drop upload plug-in, includingAjaxUpload and progress bar effects. The idea of writing this plug-in is to keep it very simple. Unlike other plug-ins, there are a lot of tags and provide some Hack methods to make it compatible wi
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.