yap's avatar
Level 2

File upload and URL

I uploaded files using this code :

$file = $request->file('project_img'); $ext = $file->extension(); $filename = $p_id.".".$ext; $file->storeAs('img', $filename);

The file is saved under storage/app/img and the file name in my database table , please how do i reference the file url in src attribute.

0 likes
4 replies
Snapey's avatar

The storage/app folders are private to your code and NOT available to the public.

You need to either save the image in something like public/img or create a symlink to make the files appear that they are in the public folder.

ftrillo's avatar

@Snapey is right. For some reason I thought you wanted to do something else with the file other than putting it in the src attribute of an img tag.

yap's avatar
Level 2

Thank you for the help.

Please or to participate in this conversation.