but in laravel 5.3 image name converted into md5 hash and saved to disk, the name will be something like this "df91c54c4ad5d78f43704f71d256a5e9.jpeg".
My concern is how can i get saved file name in laravel 5.3 and also $path variable return only string of image uploaded path.
If you do not want a file name to be automatically generated, you may use the storeAs method, which accepts the path, file name, and disk name as its arguments:
Pass the location you want to store the file, and the name of the file. The name could be the getClientOriginalName()
yea, but i want to generate image name automatically, I want laravel to return whole image object instead of just path string and that will be more flexible to work with when you have separate table for image and want to store all image information.
When you get an uploaded file from a request you get an UploadedFile instance. That object has a method hashName() that generates an md5 has of the file contents. here is a link to the api.
The hashName method is exactly what Laravel calls in the store method.
If you call
$request->image->hashName();
You will get the same name that Laravel generates when it creates the file name during the store method.