how to read FormData object in Laravel
You can do this.
// get the `UploadedFile` object$file = $request->file('file_name');$file = $request->file_name;// get the original file name$filename = $request->file('file_name')->getClientOriginalName();$filename = $request->file_name->getClientOriginalName();
Check out the documentation for more information https://laravel.com/docs/5.4/requests#retrieving-uploaded-files
The api methods available on the uploaded file http://api.symfony.com/3.0/Symfony/Component/HttpFoundation/File/UploadedFile.html
The code bellow is working for me:
$("#your_form").submit(function(e){ e.preventDefault(); var form = $(this); var url = form.attr("action"); var data = new FormData(form[0]); $.ajax({ url: url, type: 'POST', data: data, cache: false, processData: false, contentType : false, success: function (data) { console.log(data); }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR, textStatus, errorThrown); } });});
my problem was in property contentType. So, I set as false and it's ok!