0
I have a question when I will save the images coming from jquery with PHP json_encode.
I have this jquery code to get the images
$('#drag-and-drop-zone').dmUploader({
url: 'upload.php',
dataType: 'json',
allowedTypes: 'image/*',
/*extFilter: 'jpg;png;gif',*/
onInit: function(){
$.danidemo.addLog('#arquivos_cliente', 'default', 'Plugin initialized correctly');
},
onBeforeUpload: function(id){
$.danidemo.addLog('#arquivos_cliente', 'default', 'Starting the upload of #' + id);
$.danidemo.updateFileStatus(id, 'default', 'Uploading...');
},
onNewFile: function(id, file){
$.danidemo.addFile('#demo-files', id, file);
},
onComplete: function(){
$.danidemo.addLog('#arquivos_cliente', 'default', 'All pending tranfers completed');
},
onUploadProgress: function(id, percent){
var percentStr = percent + '%';
$.danidemo.updateFileProgress(id, percentStr);
},
onUploadSuccess: function(id, data){
$.danidemo.addLog('#arquivos_cliente', 'success', 'Upload of file #' + id + ' completed');
$.danidemo.addLog('#arquivos_cliente', 'info', 'Server Response for file #' + id + ': ' + JSON.stringify(data));
$.danidemo.updateFileStatus(id, 'success', 'Upload Completes');
$.danidemo.updateFileProgress(id, '100%');
},
onUploadError: function(id, message){
$.danidemo.updateFileStatus(id, 'error', message);
$.danidemo.addLog('#arquivos_cliente', 'error', 'Failed to Upload file #' + id + ': ' + message);
},
onFileTypeError: function(file){
$.danidemo.addLog('#arquivos_cliente', 'error', 'File \'' + file.name + '\' cannot be added: must be an image');
},
onFileSizeError: function(file){
$.danidemo.addLog('#arquivos_cliente', 'error', 'File \'' + file.name + '\' cannot be added: size excess limit');
},
/*onFileExtError: function(file){
$.danidemo.addLog('#arquivos_cliente', 'error', 'File \'' + file.name + '\' has a Not Allowed Extension');
},*/
onFallbackMode: function(message){
$.danidemo.addLog('#arquivos_cliente', 'info', 'Browser not supported(do something else here!): ' + message);
}
});
I got the status with PHP json_encode
echo json_encode(array('status' => 'ok'));
How would I get the name of each image sent, so that later I can write to a folder?
Give a var_dump($_FILES) to upload.php and put the result here
– AnthraxisBR
returns this error Status: Syntaxerror: Unexpected token a in JSON at position 0
– Wagner Martins Bodyboard
I tried echo json_encode(array( 'status' => 'ok', 'name' => $_FILES['afile']['name'] ); returned "status":"ok","name":null
– Wagner Martins Bodyboard
Make a jsfiddle.net with your html and this code that sends the upload, I never used this plugin, just need to see how it sends the upload
– AnthraxisBR
https://jsfiddle.net/t5p1c2s5/ ta ai fiz sem o CSS, because I don’t think you need to understand how you pass the file, I never used this plugin tbm so my question
– Wagner Martins Bodyboard
Man, I was seeing, this plugin ta without att 4 years, and there are no examples, take a look at this: http://www.dropzonejs.com/ , much easier and updated
– AnthraxisBR
Perfect Anthraxisbr !
– Wagner Martins Bodyboard