![]() |
Hi,
I am working on an application that will enable admin users to upload images to be used inside posts. Is there a way to tell the application that for example the public/images folder is not inside the public folder but let's say /home/user/myproject/sharedassets/images which is the server's path (the codeigniter application being inside the folder myproject) ? Thanks for your help
seems a complicated approach , with capacity for broken URL .
First to display any image in any post all you need is the image name and where it is. Im my blog article I get image displayed using Code: <img src =".base_url('blogImages')."/".esc($blog['image'])."> that code is in a view that will display a blog article Code: $blog['image']; all blog images are stored in a directory called blogImages. so i use constant base_url() and that directory name to reference image Code: base_url('blogImages') ways of getting stuff dfrom reuest have chnagedf i think but here is a legacy Code: $this->imageFile = $this->request->getFile('userfile'); step to shift image to where i want Code: $this->imageFile->move('blogImages', $this->imageSlug ); then : Code: $this->imageFile->move(ROOTPATH.'sharedassets/images ', 'name you want ot give image ');
The reason I am looking for a solution is so I can make upgrades on the application without risking to loose uploaded files. I used this structure with rails applications in the past, all assets remaining stored independently. That was very flexible for deploying new app releases.
While searching, it looks like what might answer my needs is to use the publisher library https://codeigniter.com/user_guide/libra...isher.html . Looking at the examples, it feels like what this does basically is to copy files from a folder into the public one, so that duplicates files on the server side. Am I correct? Would there be a solution to not duplicate the files?
You cannot make files not in public/ accessible from the browser.
Alternatively, you should write your own handler to read the file and send a Response (https://www.php.net/manual/en/function.readfile.php). But this will cause an additional load on the disk.
Thanks for confirming the impossibility. I will try to use the publisher library to see if I manage to do something with it (if anyone has a example I can look at in addition to those in the documentation, that'd be super helpful).
Simple copy-paste files
https://github.com/neznaika0/codeigniter...Publishers
Why don't you just create a symlink in the public folder?
Code: $ cd public/ |
Welcome Guest, Not a member yet? Register Sign In |