- Timestamp:
- 02/07/12 17:12:53 (3 months ago)
- Location:
- plugins/apostropheMediaEnhancementsPlugin/trunk
- Files:
-
- 3 added
- 3 modified
-
lib/action/BaseaEnhancedMediaActions.class.php (modified) (1 diff)
-
lib/toolkit (added)
-
lib/toolkit/BaseaEnhancedMediaTools.class.php (added)
-
lib/toolkit/aEnhancedMediaTools.class.php (added)
-
modules/aMedia/templates/html5UploadSuccess.php (modified) (2 diffs)
-
web/js/apostrophe.html5.uploader.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostropheMediaEnhancementsPlugin/trunk/lib/action/BaseaEnhancedMediaActions.class.php
r4551 r4556 12 12 if ($request->getMethod() == "POST") 13 13 { 14 if (isset($_GET['aFile'])) { 15 $this->file = new qqUploadedFileXhr(); 16 } elseif (isset($_FILES['aFile'])) { 17 $this->file = new qqUploadedFileForm(); 18 } 14 $files = aEnhancedMediaTools::getInstance()->handleHtml5Upload($request); 19 15 20 var_dump($this->file); 16 var_dump($files); 17 die; 21 18 } 22 19 } -
plugins/apostropheMediaEnhancementsPlugin/trunk/modules/aMedia/templates/html5UploadSuccess.php
r4551 r4556 1 1 <h1>Drag and Drop Upload! -- REMIX</h1> 2 2 3 <form> 4 <input id="fileupload" type="file" name="aFile[]" multiple> 3 <form enctype="multipart/form-data" method="POST" action="/admin/media/html5Upload"> 4 <?php /*<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo ini_get('upload_max_filesize') ?>" /> */ ?> 5 <input id="fileupload" type="file" name="aFile[]" multiple /> 6 <input type="submit" /> 5 7 </form> 6 8 … … 19 21 $('#fileupload').aFileUploader({ 20 22 'dragenter': function () { console.log("dragenter"); }, 21 'dragleave': function () { console.log("dragleave"); } ,22 'invalidFile': function (file) { console.log(file.name + " is invalid."); },23 'ajaxTransferSuccess': function(data) { console.log(data); }23 'dragleave': function () { console.log("dragleave"); } 24 //'invalidFile': function (file) { console.log(file.name + " is invalid."); }, 25 //'ajaxTransferSuccess': function(data) { console.log(data); } 24 26 }); 25 27 }); -
plugins/apostropheMediaEnhancementsPlugin/trunk/web/js/apostrophe.html5.uploader.js
r4551 r4556 14 14 "name": "aFile", 15 15 "url": "/admin/media/html5Upload", 16 "maxAjaxUploads": 1, 16 17 17 18 // Drag handlers … … 56 57 $input.bind("change", function () { 57 58 handleFiles(this.files); 59 //$input.closest('form').submit(); 58 60 }); 59 61 } else { … … 70 72 function handleFiles(files) 71 73 { 74 var requests = []; 75 72 76 for (var i = 0; i < files.length; i++) { 73 77 … … 75 79 76 80 if (file.size > 0) { 77 upload(file);81 requests.push(upload(file)); 78 82 } 79 83 else … … 86 90 87 91 } 92 93 function executeNextRequest() { 94 var req = requests.shift(); 95 96 if (typeof(req) == 'function') { 97 $.when(req()).then(function(){ executeNextRequest();}); 98 } 99 } 100 101 for (var i = 0; i < defaults.maxAjaxUploads; i++) 102 { 103 executeNextRequest(); 104 } 88 105 } 89 106 … … 119 136 function upload(file) 120 137 { 138 // deferred object will allow us to chain events based on resolution of ajax 139 var deferred = $.Deferred(); 140 var aSendFunction; 141 121 142 // xmlHttpRequest is the easiest way to deal with posting data 122 143 var xmlHttpRequest = new XMLHttpRequest(); … … 133 154 } 134 155 } 156 deferred.resolve(); 135 157 } 136 158 } … … 142 164 if (window.FileReader) { // Firefox and Chrome 143 165 var fileReader = new FileReader; 166 167 var aSendFunction = null; 144 168 145 169 // attach events to the FileReader … … 181 205 182 206 xmlHttpRequest.setRequestHeader("Content-Type", "multipart/form-data;boundary=" + boundary); 183 xmlHttpRequest.sendAsBinary(data); 207 208 aSendFunction = function() { 209 xmlHttpRequest.sendAsBinary(data); 210 211 return deferred.promise(); 212 } 184 213 } else if (window.FormData) { // Chrome 185 214 var formData = new FormData(); 186 215 formData.append(defaults.name, file); 187 xmlHttpRequest.send(formData); 216 217 aSendFunction = function() { 218 xmlHttpRequest.send(formData); 219 220 return deferred.promise(); 221 } 188 222 } 189 223 } else if (window.FormData) { // Safari 190 224 var formData = new FormData(); 191 225 formData.append(defaults.name, file); 192 xmlHttpRequest.send(formData); 193 } 226 227 aSendFunction = function() { 228 xmlHttpRequest.send(formData); 229 230 return deferred.promise(); 231 } 232 233 } 234 235 return aSendFunction; 194 236 } 195 237 });

