Welcome Guest, Not a member yet? Register   Sign In
Security and File Upload in CodeIgniter: Best Practices to Keep Images Out of the Pub
#1

I'm working on a project in CodeIgniter and I'm looking for a secure way to handle file uploads, such as images, without directly exposing them in the public folder. I would like to know the best practices and recommended methods for securely handling file uploads in CodeIgniter while keeping the files out of the public folder to prevent direct web access. Thank you for sharing your experiences and suggestions!
Reply
#2

(This post was last modified: 08-02-2023, 04:16 AM by luckmoshy.)

do 
PHP Code:
$filepath WRITEPATH 'uploads/' $img->store(); 
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#3

(This post was last modified: 08-02-2023, 05:23 AM by tarcisiodev1.)

(08-02-2023, 04:15 AM)luckmoshy Wrote: do 
PHP Code:
$filepath WRITEPATH 'uploads/' $img->store(); 

But if I display this link to the image/file in the view, will it be accessible even though it is not in the public folder, or do I need to make any other configuration? Is there a specific route or controller method I should set up to handle file requests securely and serve them with the necessary headers?

(08-02-2023, 04:15 AM)luckmoshy Wrote: do 
PHP Code:
$filepath WRITEPATH 'uploads/' $img->store(); 

What method should I use to access files with non-public access levels and render them in the view without being in the public folder?
Reply
#4

You need create a method to read the image file and send it's contents to the browser with the correct header.
See this for some hints on how to do with straight PHP:
https://stackoverflow.com/questions/2977...-using-php
Reply
#5

[RESOLVED] Hide Image Source using PHP and Sessions
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(08-02-2023, 10:48 PM)InsiteFX Wrote: [RESOLVED] Hide Image Source using PHP and Sessions


I really appreciate your help,


Thank you very much
Reply




Theme © iAndrew 2016 - Forum software by © MyBB