djo57393's avatar

Cannot upload big files to laravel

I am trying to upload image from vue js , when the file size is less than 1mo it is working but when it exceed , laravel return 400 error bad request I already checked if it is from vue but it is with laravel the error, i already use storage but it is still not working Does anyone know how to solve this ?

    public function store($id,Request $request)
    {
    if(!$request->hasFile('image')) {
        return response()->json(['upload_file_not_found'], 400);
    }
    $file = $request->file('image');
    if(!$file->isValid()) {
        return response()->json(['invalid_file_upload'], 400);
    } 
    $path = Storage::putFile('logements', $request->file('image'));
    return response()->json($path);
    }
0 likes
1 reply
undeportedmexican's avatar

I know I've struggled with this in the past, unfortunately, I cannot remember the exact way I solved it. It has something to do with the limits set by both PHP and (I think) the client uploading the file.

So what you're 'supposed' to do is you need to upload the file in 'chunks' and then 'glue' all the chunks in the server. You may want to google something around it, as I said, I cannot remember if this is how I solved it or;

The other thing you can do is modify PHP config to accept larger uploads. Tho, I believe this is frowned upon.

Please or to participate in this conversation.