Welcome Guest, Not a member yet? Register   Sign In
Image to public or writable folder
#1

All,
The documentation gives a example and that is the standard that file/images will stored in de writable folder for example the uploads folder.
But reading here in the forum they say store it in the public folder.
Why in the public folder and not in the standard folder named writable?
The writable folder is save for the outside world and the public folder is accessible for everyone in my opinion.

Andre
Reply
#2

I will advise you to save to public folder because image need to be publicity accessable.
Reply
#3

The documentation gives a example and that is the standard that file/images will stored in de writable folder for example the uploads folder.
But reading here in the forum they say store it in the public folder.
Reply
#4

Yea we all aware of that because if u try to upload the image to writable folder and try to access it the system will return a relative path to the image instead of norm image url we all use with. Use FCPATH.'path/to/director ' do not use WRITABLE.'path/to/directly '.

Anyway your choice.
Reply
#5

(This post was last modified: 03-13-2022, 12:11 AM by snelledre.)

(03-12-2022, 11:41 AM)seunex Wrote: Yea we all aware of that because if u try to upload the image to writable folder and try to access it the system will return a relative path to the image instead of norm image url we all use with. Use FCPATH.'path/to/director ' do not use WRITABLE.'path/to/directly '.

Anyway your choice.

I use an method to show the image from the writable folder.

PHP Code:
public function image($image=null)
    {
        if ($image) {
            
            $path 
WRITEPATH 'uploads/installation_images/' $image;
        
            $finfo 
= new \finfo(FILEINFO_MIME);
            
            $type 
$finfo->file($path);
            
            header
("Content-Type: $type");
            header("Content-Length: " filesize($path));
            
            readfile
($path);
            exit;
        }
    }


All you see in the html is:

<
img src="/admin/installations/1647118918_0617c078466e88edf636.jpg/image" width="200" height="200" alt="" class="mb-3" name="image" id="image"
Reply




Theme © iAndrew 2016 - Forum software by © MyBB