i want to automatically checking a file, if the name file already exist in database its will be remove from dropzone. here is the dropzone option:
Dropzone.options.dropzone =
{
maxFilesize: 12,
maxFiles:10,
acceptedFiles: ".jpeg,.jpg,.png,.gif",
timeout: 20000,
parallelUploads:10,
autoProcessQueue : false,
addRemoveLinks:true,
init:function(){
this.on("addedfile",function(file){
$.ajax({
url:"{{ route('photo.cek') }}",
type: 'GET',
data:{
yohanes:file.name
},
dataType: 'json',
success: function(data){
// var myDropzone;
console.log(data);
alert(data.success);
// var myDropzone = Dropzone.forElement(".dropzone");
// myDropzone.removeFile(file);
// alert(data.success);
$(file.previewElement).remove();
}
});
})
here is my controller :
public function cek(Request $request)
{
$till_code = $request->yohanes;
$cek=DB::table('image_uploadeds')
->where('name','=',$till_code)
->first() ;
if ($cek !=null) {
return response()->json(array('success' => 'Till Code Already Exist !',
'till_code'=> $till_code));
}
}
the image preview in dropzone is remove, but the data is still there. after i press the button for processqueque, the removed data still processed.