[Solved] Image Manipulation Class |
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?
$path_save = ROOTPATH . 'public/assets/images/test.jpg';
or $path_save = FCPATH . 'assets/images/test.jpg'; https://codeigniter4.github.io/userguide...-constants
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). (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! (01-17-2020, 10:57 PM)littlej Wrote: Hello mate ! Thanks! |
Welcome Guest, Not a member yet? Register Sign In |