Reputation:
I have stored image in Laravel storage. When I get it, it gets the file path but says page not found,
My controller code,
$email = $request['email'];
$first_name = $request['first_name'];
$password = bcrypt($request['password']);
$postdata = $request['user_image'];
$user_name = $request['user_name'];
$myfile = time().str_random();
$image = $request->file('user_image');
$user_image = time() . '.' . $image->getClientOriginalExtension();
Image::make($image)->resize(300, 300)->save( storage_path('/' . $user_image ) );
$user = new User();
$user->email = $email;
$user->first_name = $first_name;
$user->password = $password;
$user->user_image = $user_image;
$user->user_name = $user_name;
$user->save();
File path I get when I call the file,
http://localhost:8000/storage/1553413340.png
Upvotes: 2
Views: 85
Reputation: 304
By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public. This convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.
To create the symbolic link, you may use the storage:link Artisan command:
php artisan storage:link
Upvotes: 1