U
U
Uglik2016-04-14 23:26:25
Laravel
Uglik, 2016-04-14 23:26:25

Replace Request with another value?

Hello
The situation is this:
C form data arrives, validated and we get them in the controller.
There is an image file in $request->file and it contains a temporary path to the file.
It needs to be rewritten to another value.
I try $request->merge( array( 'file' => 'new value' ) ); and nothing works.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gregory, 2016-04-15
@difiso

Even by rewriting the path value, you will not move the file, but only overwrite the path value and lose the path to this file. The file itself is located in a temporary folder, which means that after the reboot the file will not be there (or earlier - depending on the OS policy for cleaning up this directory). So, you will have to move the file yourself and immediately. Use the Storage facade for this .
The documentation describes how to configure and use it. You need a local driver , where you need to specify the path to the users. If something needs to be stored in usersand something else, thenStoragecan work with several providers specified in the configuration at once. Well, write a relative name to the database, which is obtained as a result of moving the file to the appropriate folder.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question