I am trying to upload documents created on the client side (images currently) using Dropzone.js .
var myDropzone = new Dropzone("form.dropzone", {
autoProcessQueue: true
});
Once the client has finished his work, he just needs to click the save button, which calls the save function:
function save(myDocument) {
var file = {
name: 'Test',
src: myDocument,
};
console.log(myDocument);
myDropzone.addFile(file);
}
The .log () console will return the contents of my document to me
data:image/png;base64,iVBORw0KGgoAAAANS...
At this point, we see that the progress bar is loading the document into the forwarding zone, but the download failed.
Here is my (standard dropzone) HTML form:
<form action="/upload" enctype="multipart/form-data" method="post" class="dropzone">
<div class="dz-default dz-message"><span>Drop files here to upload</span></div>
<div class="fallback">
<input name="file" type="file" />
</div>
</form>
I have a Symfony2 controller that receives a mail request.
$request = $this->get('request');
$files = $request->files;
$do = $service->upload($files);
Downloading from dropzone (by dragging or clicking) works, and loading successfully, but using the myDropzone.addFile () function returns me an empty object in my controller:
var_dump($files);
return
object(Symfony\Component\HttpFoundation\FileBag)
["parameters":protected]=>
array(0) {
}
}
, var .
JS- (var img = new Image()...), - .
!