I have an issue in my laravel ajax application,
I cant upload images/files through ajax POST.
here is my code.
Ajax..
/*Add new catag
Two things to change:
Change your js file from:
data:{
logo:new FormData($("#upload_form")[0]),
},
To:
data:new FormData($("#upload_form")[0]),
Because you would like to send the whole form.
In your html:
Add a name to your file input field
<input type="file" class="form-control" id="catagry_logo">
To:
<input type="file" name="logo" class="form-control" id="catagry_logo">
it doesn't work for me because of dataType:'json'
. If anyone gets error just remove dataType:'json'
.
Check in your controller what you get when you post:
echo dd(Input::all());
Check files object in php. This in PHP:
$_FILES
Request::file("logo");
Yeah, you're not really posting any data? Is the form really posting?