Я хочу интегрировать поля dropzone с другими полями ввода после нажатия кнопки отправки, моя форма работает до нажатия кнопки отправки. Может кто-нибудь помочь с после отправки кнопки dropzone изображения с другими полями, а также мое описание tinymce показывает в базе данных undefined
мой маршрут
Route::post('project/image-upload', 'ProjectsController@processImageUpload')->name('projects-image-upload');
и контроллер
public function processImageUpload(Request $request)
{
$image = $request->file('file');
$rename = date('YmdHis') . '-' . time() . '-' . $image->getClientOriginalName();
$dir = './images/project-images/';
$image->move($dir,$rename);
$image = $dir.$rename;
$project = new Projects();
$project->project_name = $request->post('project_name');
$project->project_location = $request->post('project_location');
$project->project_price = $request->post('project_price');
$project->project_status = $request->post('project_status');
$project->project_client_id = $request->post('project_client_id');
$project->project_date = $request->post('project_date');
$project->project_total_member = $request->post('project_total_member');
$project->project_description = $request->post('project_description');
$project->project_image = $image;
$project->save();
$notification = array(
'message' => 'Project Create Successfully !',
'alert-type' => 'success'
);
return redirect()->back()->with($notification);
}
и клинок
<form class="form form-vertical" novalidate action="{{route('projects-image-upload')}}" method="post" enctype="multipart/form-data">
@csrf
<input type="text" id="project_name" class="form-control" name="project_name"
placeholder="Project Name" required data-validation-required-message="This Project Name field is required">
<input type="text" id="project_location" class="form-control" name="project_location" placeholder="Project Location" required data-validation-required-message="This Project Location field is required">
<div id="dZUpload" class="dropzone">
<div class="dz-default dz-message"><span>Your Custom Message</span</div>
</div>
</form>
и скрипт
<script>
Dropzone.autoDiscover = false;
$(document).ready(function () {
// Dropzone.autoDiscover = false;
$("#dZUpload").dropzone({
url: "/project/image-upload",
sending: function(file, xhr, formData) {
formData.append("_token", "{{ csrf_token() }}");
formData.append("project_name", jQuery("#project_name").val());
formData.append("project_location", jQuery("#project_location").val());
formData.append("project_price", jQuery("#project_price").val());
formData.append("project_status", jQuery("#project_status").val());
formData.append("project_client_id", jQuery("#project_client_id").val());
formData.append("project_date", jQuery("#project_date").val());
formData.append("project_total_member", jQuery("#project_total_member").val());
formData.append("project_description", jQuery("#project_description").val());
},
addRemoveLinks: true,
success: function (file, response) {
// var project_image = response;
file.previewElement.classList.add("dz-success");
console.log("Successfully uploaded :" );
},
error: function (file, response) {
file.previewElement.classList.add("dz-error");
}
});
});
</script>
Ссылка полного кода