You can also do with the following code:
<script>
Dropzone.options.myAwesomeDropzone = false;
Dropzone.autoDiscover = false;
$("#image").dropzone({
url: "http://someserver.com/upload.php",
paramName: "image", // The name that will be used to transfer the file
maxFilesize: 2, // MB
maxFiles: 5,
parallelUploads: 5,
addRemoveLinks: true,
dictMaxFilesExceeded: "You can only upload upto 5 images",
dictRemoveFile: "Delete",
dictCancelUploadConfirmation: "Are you sure to cancel upload?",
accept: function (file, done) {
console.log(file)
if ((file.type).toLowerCase() != "image/jpg" &&
(file.type).toLowerCase() != "image/gif" &&
(file.type).toLowerCase() != "image/jpeg" &&
(file.type).toLowerCase() != "image/png"
) {
done("Invalid file");
}
else {
done();
}
},
init: function () {
var mockFile = { name: "myimage.jpg", size: 12345, type: 'image/jpeg' };
this.addFile.call(this, mockFile);
this.options.thumbnail.call(this, mockFile, "http://someserver.com/myimage.jpg");
}
});
</script>
EDIT
Since update of Dropzone 4.0 init
function can be called as:
init: function () {
var mockFile = { name: "myimage.jpg", size: 12345, type: 'image/jpeg' };
this.options.addedfile.call(this, mockFile);
this.options.thumbnail.call(this, mockFile, "http://someserver.com/myimage.jpg");
mockFile.previewElement.classList.add('dz-success');
mockFile.previewElement.classList.add('dz-complete');
}