I'm trying to upload images to the database using Ajax Jquery.It works fine for small files (less than 100kb) and gets uploaded to the database. I have changed the php.ini for file uploading limits(upload_max_filesize = 40M) and post upload limits to 40M(post_max_size = 41M) and tried to upload an image with 300kb but still nothing. When i click on console, i see "No response data".
Controller
public function store(Request $request)
{
// ($request->all());
$formInput=$request->except('filename');
$product = product::create(array_merge($formInput, [
'seller_id'=> Auth::user()->id,
'user_id' => Auth::user()->id
]));
foreach ($request->photos as $photo) {
$filename = $photo->store('public/photos');
ProductsPhoto::create([
'product_id' => $product->id,
'filename' => $filename
]);
}
}
Ajax
var token = $("#token").val();
$(document).ready(function(){
$("#btn").click(function(){
var url = '';
var form = $('form')[0];
var formData = new FormData(form);
formData.append('_token', token); // adding token
$.ajax({
url: url,
data: formData,
type: 'POST',
contentType: false,
processData: false,
success:function(data){
console.log(data);
}
});
});
});
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/37UIqp8
via IFTTT
Python Line Plot Using Matplotlib
RépondreSupprimerHow to save figure in matplotlib pyplot
Python Matplotlib 3D Plot
NextworkX Python Overview
How to display doc file in PHP from database
How to convert text to speech using PHP
How to create a multiple choice quiz in PHP and MySQL
Python Convert XML to CSV