Uploading file from laravel application using POST method causing Internal Server Error I have a simple form ..
<form action="/products" method="POST"
enctype="multipart/form-data" id="js-upload-form">
<input type="file" name="csv" id="csv" multiple>
<button type="submit" class="btn btn-primary btn-flat">Upload Files</button>
</form>
using routes ...
Route::post('/products', function(Illuminate\Http\Request $request) {
return 'Got it';
});
Form submitted ... but I get internal server error 500 as response...
am i missing something?
Have you searched this forum for uploading as there has been many prior answers to this.
Well your route is different then your action...
'/products/import/csv' and '/products'
Sorry I have changed the route it was a mistake during submission in my post. Corrected like below:
Route::post('/products', function(Illuminate\Http\Request $request) {
return 'Got it';
} );
Still the same HTTP 500 error code responded. I have tried uploading 70K size photo and 10K size csv file. Is this related to file size?
But I get a black page as reponse. I expected a page should have 'Got it' written on it.
I have searched the forum but I found nothing related getting HTTP 500 code replied for a file upload. It should be as simple as it is to do in laravel.
Please check your laravel.log file more detailed error.
Based on your provided markup, you're missing the csrf token hidden input. Try adding that and see if that fixes the problem.
Don't do in routes file make controller and call function related to this operation.
You can't just return a string in laravel. It won't allow that. Try to return an response like this. If you want to return an String just dd.
Route::post('/products', function(Illuminate\Http\Request $request) {
return response('Got IT!', 200);
} );
Also you need the csrf-token as mentioned above.
Please sign in or create an account to participate in this conversation.