diff --git a/javascript/dropzone/demo/.gitignore b/javascript/dropzone/demo/.gitignore new file mode 100644 index 0000000..e2c0f57 --- /dev/null +++ b/javascript/dropzone/demo/.gitignore @@ -0,0 +1,2 @@ +bower_components +!.gitignore diff --git a/javascript/dropzone/demo/UploadImage.php b/javascript/dropzone/demo/UploadImage.php new file mode 100644 index 0000000..c92eaa7 --- /dev/null +++ b/javascript/dropzone/demo/UploadImage.php @@ -0,0 +1,34 @@ +// This is just an example, change it to your specific needs +// This example is intended for images + +getClientOriginalExtension(); + $file->move( + FRONTEND_FILES_PATH . '/Profiles/acquisitions/source', + $filename + ); + Model::generateThumbnails( + FRONTEND_FILES_PATH . '/Profiles/acquisitions/', + FRONTEND_FILES_PATH . '/Profiles/acquisitions/source/' . $filename + ); + + return $filename; + }, + $this->get('request')->files->all() + ); + + $this->output(self::OK, $files); + } +} diff --git a/javascript/dropzone/demo/bower.json b/javascript/dropzone/demo/bower.json new file mode 100644 index 0000000..cc5b7e1 --- /dev/null +++ b/javascript/dropzone/demo/bower.json @@ -0,0 +1,19 @@ +{ + "name": "dropzone", + "homepage": "https://github.com/sumocoders/snippets", + "authors": [ + "Mathias Helin " + ], + "description": "", + "main": "", + "moduleType": [], + "license": "MIT", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/javascript/dropzone/demo/index.html b/javascript/dropzone/demo/index.html new file mode 100644 index 0000000..689499b --- /dev/null +++ b/javascript/dropzone/demo/index.html @@ -0,0 +1,17 @@ + + + + + + + + +
+
+
+ + + + + + diff --git a/javascript/dropzone/demo/script.js b/javascript/dropzone/demo/script.js new file mode 100644 index 0000000..8f5d8ac --- /dev/null +++ b/javascript/dropzone/demo/script.js @@ -0,0 +1,55 @@ +(function() { + + // Example of existing files + var item = { + "images": [{ + "name": "image1", + "url": 'http://placehold.it/200x200', + "filesize": 1234 + }, + { + "name": "image2", + "url": 'http://placehold.it/400x400', + "filesize": 4346 + }] + }; + + // Disable autodiscover + Dropzone.autoDiscover = false; + var $dropzone = $('.dropzone'); + $dropzone.dropzone({ + url: '/frontend/ajax', + params: { + 'fork[module]': 'module', + 'fork[action]': 'action' + }, + uploadMultiple: true, + addRemoveLinks: true, + // maxfiles can be set if needed + maxfiles: 3, + // Comma separated list of accepted file types + acceptedFiles: 'image/*, application/pdf', + // Set some events at init + init: function() { + var dropzone = this; + + // example of how to show existing items + $.each(item.images, function(index, image) { + console.log(image); + var realfile = {name: image.name, size: image.filesize, accepted: true}; + dropzone.emit('addedfile', realfile); + dropzone.emit('thumbnail', realfile, image.url); + dropzone.emit('complete', realfile); + // push this to the list so dropzone knows how many images are already uploaded + dropzone.files.push(realfile); + }); + + // example to block the upload if maxfiles is reached + dropzone.on('maxfilesexceeded', function(file) { + dropzone.removeFile(file); + $dropzone.find('.dz-max-files-exceeded').fadeIn('slow').delay(3000).fadeOut('slow'); + }); + } + }); + +})();