Level 1
Hi, I face the same problem. Have you found any solution?
best regards
Hey guys, I've been stuck on this for a while now.
The dropzone upload is working and saving to the database. except that it's making a post request twice, creating 2 forms, one with just the uploaded file and another with the actual form data.
even with
autoProcessQueue: false,
and the submit button having a click function of
$('#submit-all').click(function(formData) {
e.preventDefault();
myDropzone.processQueue();
});
If anyone can spot what's wrong here I'd really appreciate it!
View
<form action="{{url('/save_information')}}" method="POST" name="amendment_form" enctype="multipart/form-data">
<meta name="csrf-token" content="{{csrf_token()}}" />
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="application_id" id="application_id" value="{{ $application_id }}">
<div class="form-group">
<div class="col-md-12">
<label for="ex1"></label>
<input class="form-control" type="text" id="title" name="title" placeholder="Document Title" value="{{$trustDocument->title or ""}}" style="width:100%;padding:10px;height:60%;" required>
</div>
<br>
<div class="dropzone dropzone-previews" id="my_awesome_dropzone" style="margin-top:80px;">
<input type="hidden" name="image" value="{{ $trustDocument->image }}">
</div>
jquery
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("#my_awesome_dropzone",{
url: "/save_information",
uploadMultiple: false,
autoProcessQueue: false,
addRemoveLinks: true,
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 10, // MB
sending: function(file, xhr, formData) {
formData.append("_token", "{{ csrf_token() }}");
}
});
$('#submit-all').click(function(formData) {
e.preventDefault();
myDropzone.processQueue();
});
controller function
if (Requestt::hasFile('file')) {
$image = Requestt::file('file');
$location = public_path('images/');
$filename = time() . '.' . $image->getClientOriginalExtension();
$image->move($location, $filename);
$trustDocument->image = $filename;
}
}
$trustDocument->save();
Please or to participate in this conversation.