The original name when loading the file?

So upload the file to the server
if($request->hasFile('img')) {
 $file = $request->file('img')->store('uploads', 'public');
}

everything works,but the file name is
jLyiDxpJWkhiImPOBVwNo6yd3HQciCKTAPLIWsAv.jpeg
Tell me how to return back to normal file name,
March 19th 20 at 08:57
1 answer
March 19th 20 at 08:59
This is the correct name of the file, which eliminates duplicates within one folder, so the contents of the file did not periapicales. If you want, you can read the documentation on laravel, which says how it should be done with the methods of this class.

A brief excerpt
By default, the store method will generate a unique ID to serve as the file name. The file's extension will be determined by examining the file's MIME type. The path to the file will be returned by the store method so you can store the path including the generated file name, in your database.


If you want to save the original file name, there is below also there is a solution. In the method storeAs you can pass a second parameter with the file name.

$path = $request->file('avatar')->storeAs(
 'avatars', $request->user()->id
);
That is the norm ? - Myrtle commented on March 19th 20 at 09:02
@Myrtle, Yes. This is the right approach, which originally spelled out in the documentation. I recommend to read it from cover to cover, because Laravel she's good. Reading English Russian translations were outdated and disgusting. - van_Wiegand commented on March 19th 20 at 09:05
@van_Wiegand, "Read from cover to cover" I do not suggest because of the sense in this.

Enough to read the table of contents and the first thing to go, it will be faster and better for asking the question. - carley.Jerde commented on March 19th 20 at 09:08
@carley.Jerde, I suggest. Because without reading the documentation, you are not to know about any opportunity Caravel, and then to invent a Bicycle. Over the years I have seen these situations hundreds of times. - cleveland commented on March 19th 20 at 09:11
@cleveland, your opinion. - carley.Jerde commented on March 19th 20 at 09:14
@carley.Jerde, not just him. I'm part of their work quite often in contact with June and often ignorance of the capabilities of laravale makes them more difficult to source at times. - van_Wiegand commented on March 19th 20 at 09:17
Reading the documentation "from cover to cover" will not reduce the complexity of the code June. From the UPS's practice. I specifically mentioned "Enough to read the table of contents," perhaps it is too easy wording, but the meaning of it is to understand what is there and return to the topic when you start to use it.

Stupid read the documentation "because we should", I believe, meaningless. - carley.Jerde commented on March 19th 20 at 09:20
@carley.Jerde, it is necessary to read from cover to cover, rather than memorize. Do you hear the difference? Like a book, maybe not very interesting but useful. Then head make up its "table of contents". And then return to the section will be easier.

This approach is backed by years of practice and observation teach and help them. So I think that my opinion is weightier. - cleveland commented on March 19th 20 at 09:23
@cleveland, again. The documentation should be read to understand what is in the framework, is also necessary. How to do it: read from "cover to cover" or practicing or watching educational videos -- the decision is purely the student or his mentor. If you novasuede someone their methods of cognition, I'm sorry.

"Years of practice, observation of June" adds no weight to your opinion by default. Since there are no representative statistics on the matter among those whom you helped. - carley.Jerde commented on March 19th 20 at 09:26
@carley.Jerde, teachers in the school also imposed methods of cognition, I'm sorry. - cleveland commented on March 19th 20 at 09:29
@cleveland, I'm Sorry you have not imposed the normal means of communication. - carley.Jerde commented on March 19th 20 at 09:32
@carley.Jerde, you are still in toxicity could charge me with, is now a fashionable word. - cleveland commented on March 19th 20 at 09:35

Find more questions by tags Laravel