From the Laravel's documentation (file uploads), the store function will generate a unique ID to serve as the file name. My code for uploading and storing the file is:
$path = $request->file('headerimg')->store('images');
Now $path
will look like this: images/sCzDxJBUnkveRLdzfhsIA7hAS8RVfPDXuJjBPgzM.jpeg
.
How can i get the filename only(sCzDxJBUnkveRLdzfhsIA7hAS8RVfPDXuJjBPgzM.jpeg
) so I can use it let's say in a database, because right now all i have is the full path.
I can do it with PHP's explode but this is not the case.
BTW, using getClientOriginalName()
will return the original filename, which is redundant since laravel is storing files with a unique ID.
Thanks.
via Theodoros80