Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the default text in dropzone.js?

I am using dropzone.js to upload files. However, I'm having difficulty changing the default text.

I've tried instantiating the dropzone class:

$(document).ready(function(){   $(".foo").dropzone({ dictDefaultMessage: "hello" }); }); 

With this markup:

    <div class="span4">       <form action="http://localhost/post" method="post" accept-charset="utf-8" id="drop3" class="foo" enctype="multipart/form-data"> </form>     </div>     <div class="span4">       <form action="http://localhost/post" method="post" accept-charset="utf-8" id="drop4" class="foo" enctype="multipart/form-data"> </form>   </div> 

This certainly gives me the ability to upload files but the default text is blank.

I tested the following:

 $(".foo").dropzone(); 

and I appear to get the same result - no default text. So.. how do I change the default text?

like image 998
Sheldon Avatar asked Jul 17 '13 14:07

Sheldon


People also ask

How do I change the default message in Dropzone?

If you are creating Dropzones Programmatically then you have to set your options like below: Dropzone. autoDiscover = false; profilePicture = new Dropzone('#profile-picture', { url: "/uploadPicture.

How does dropzone JS work?

Dropzone. js is 'a light weight JavaScript library that turns an HTML element into a "dropzone"'. Users can drag and drop a file onto an area of the page, uploading to a server. If you would like to read more how all of this works skim through the Dropzone.

What is maxFilesize in Dropzone?

I'm using Dropzone. js for my website. I'm in the need of uploading bigger files than the default maxFilesize of 500MB.

How do I remove all files from dropzone?

dropzone has the following function for removing all files. If you want to remove all files, simply use . removeAllFiles().


2 Answers

Add an element within your dropzone form as follows:

<div class="dz-message" data-dz-message><span>Your Custom Message</span></div> 
like image 164
supernifty Avatar answered Sep 19 '22 05:09

supernifty


You can change all default messages with this:

Dropzone.prototype.defaultOptions.dictDefaultMessage = "Drop files here to upload"; Dropzone.prototype.defaultOptions.dictFallbackMessage = "Your browser does not support drag'n'drop file uploads."; Dropzone.prototype.defaultOptions.dictFallbackText = "Please use the fallback form below to upload your files like in the olden days."; Dropzone.prototype.defaultOptions.dictFileTooBig = "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB."; Dropzone.prototype.defaultOptions.dictInvalidFileType = "You can't upload files of this type."; Dropzone.prototype.defaultOptions.dictResponseError = "Server responded with {{statusCode}} code."; Dropzone.prototype.defaultOptions.dictCancelUpload = "Cancel upload"; Dropzone.prototype.defaultOptions.dictCancelUploadConfirmation = "Are you sure you want to cancel this upload?"; Dropzone.prototype.defaultOptions.dictRemoveFile = "Remove file"; Dropzone.prototype.defaultOptions.dictMaxFilesExceeded = "You can not upload any more files."; 
like image 35
Sergio Cabral Avatar answered Sep 21 '22 05:09

Sergio Cabral