YuraLons's avatar

Uploading a file to the created folder

I have this code in the controller - Home - store function

 $this->validate($request, [
            ///
        ]);

        $homes = Houses::query()->create([
                '///
            ]
        );
        if ($request->hasFile('passport'))
        {
            $homes->update(['passport' => $request->file('passport')
                ->store('passport', 'public')]);
        } 

When I go to the page with the creation of a house card, I fill in all the fields and select a test document (word) and try to load it. But: the card itself is successfully created in the database, but the passport field (where the document that I uploaded should be stored) is empty, besides, Laravel will not give any errors when creating a card at home.

What have I done wrong ? Why can't I upload a document to this field?

0 likes
5 replies
Snapey's avatar

does your file get uploaded to the filesystem.

Do you have enctype="multipart/form-data" in your form declaration?

Do you have validation rules for the file upload?

YuraLons's avatar

Yes, the form contains a condition for uploading files but how to do this file check?

YuraLons's avatar
$this->validate($request, [
'passport'  => ['required', 'mimes:jpg,jpeg,png,pdf,docx', 'max:894096'],
]);

I have such a field with validation

Snapey's avatar

If validation passes then we can assume that a file was attached

how to do this file check?

look in your file system for the file...

YuraLons's avatar

No file is uploaded to the file folder.

Please or to participate in this conversation.