![]() |
[Solved] Image Manipulation Class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: [Solved] Image Manipulation Class (/showthread.php?tid=75254) |
[Solved] Image Manipulation Class - PHS - 01-17-2020 Hello! I am trying to implement the image manipulation library in my controller. But when I try to use the base_url() path, the library cannot find the path! Code: $path_save = base_url('assets/images/test.jpg'); What is the difference in using the path to the directory where the image will be saved like this: Code: base_url('assets/images/test.jpg') and this way: Code: '../public/assets/images/test.jpg' Is there a correct way to indicate the directory path to save the image? RE: Image Manipulation Class - Dedov_Evgeniy - 01-17-2020 $path_save = ROOTPATH . 'public/assets/images/test.jpg'; or $path_save = FCPATH . 'assets/images/test.jpg'; https://codeigniter4.github.io/userguide/general/common_functions.html?highlight=fcpath#core-constants RE: Image Manipulation Class - littlej - 01-17-2020 Hello mate ! When using "../", the path is relative to the location of the file on the server. When using "base_url", the path is relative to the public location of the file. "base_url" will add "https://my.domain.com/" in front, which means that the file must be publicly accessible, and must be located in the "public" folder. For instance, if we want to include a php file, we will do "include APPPATH. 'Libraries/myfile.php';". But you can not do something like "include base_url ('../app/Libraries/myfile.php');" because the "app" folder is not publicly accessible. So, it is "normal" that base_url is not working. It is used when you want to provide a public link (a link that will probably be displayed on the page for the final user). You probably don't want to use "base_url()" in your controller (at least for what you are doing). RE: Image Manipulation Class - PHS - 01-18-2020 (01-17-2020, 10:54 PM)Dedov_Evgeniy Wrote: $path_save = ROOTPATH . 'public/assets/images/test.jpg'; Hello Dedov_Evgeniy ! Your tip solved my problem. Thanks! RE: Image Manipulation Class - PHS - 01-18-2020 (01-17-2020, 10:57 PM)littlej Wrote: Hello mate ! Thanks! |