how to show an image which is stored in outside public folder
I am not getting an image. I have used these two methods but not get any output.
Basically I have stored my image outer of a public folder.
can anyone help me out of this problem?
@sinnbeck the path of image root(project_directory)/uploads/logo/
I have stored the image outside the public folder. I have created a new folder for image stored which name is uploads/folders_name...
I would really recommend that you use the storage directory and symlink it (look at the link posted earlier). Using a custom directory like that is possible but goes against how laravel was designed
If you avosolutely have to use a custom directory like that, you can either symlink it into the public directory, or create a controller for the route, that gets the raw file content and serves it back in the response
@sinnbeck So, basically I have to stored all images in a public directory or storage directory rather than a custom directory.
This is my store image code, so can you please suggest me where I have to change the code and how to pass it into images directory.
if ($request->hasFile('image')) {
if ($request->file('image')->isValid()) {
$fileName=$request->file('image')->getClientOriginalName();
$fileName =time()."_".$fileName;
//upload
$request->file('image')->move('uploads/logo', $fileName);
//column name
$records['image']=$fileName;
}
}
@sinnbeck Now I have my custom create uploads move inside the public folder and currently it is running okk.
but I have one confusion regarding the public and storage folder?
using this line of code it creates a folder uploads/logo inside public folder.
Is it a good idea to create an image structure inside the public folder either we have to change the code and store images in storage folder and get image using symlink?
plz, tell me if you have time for this...?
If they are all public then it should not be an issue. Just be sure that they get a random name to that no two names are the same. Users will need to know the exact file name to get acces to it.
Is there some reason that people can only view their own images? If so I can give you another solution perhaps :)
@sinnbeck
Basically there is no reason that people can only view their own images.
All images are stored inside the public folder. but inside the public folder file stored with their original name.
I just want to know that is there any security issueto store images in the public or storage folder?
And in this code, if I want to store imge inside storage folder, How can I do this?
@saber13812002 It's a web thing, not a Laravel thing. Plus sign is often used to represent the space character in URLs. If the filename can contain special characters, you should encode it in the URL.
But I'd avoid using special characters in filenames altogether. And never use original filenames sent by the client.