CodeIgniter Forums
[Solved] Problem on save image in public directory - 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] Problem on save image in public directory (/showthread.php?tid=78190)



[Solved] Problem on save image in public directory - PHS - 12-11-2020

I have the structure below my project:

(private directories)

/home/my_project/App/Controllers/Api/V1/FileController.php

(public directories)

/home/public_html/my_site/assets/images

I'm trying to send an Api file to the / images directory with file_put_contents but I'm not getting it. I've tried with:
file_put_contents (FCPATH. '....');
file_put_contents (APPPATH. '....');
file_put_contents (ROOT. '....');
file_put_contents (__ DIR__. '....');

I tried to change the permissions of the directory from 755 to 777.

And nothing worked.
What is the correct way to do this?


RE: Problem on save image in public directory - InsiteFX - 12-11-2020

It would help if we had a little more information, like what is your base url etc.;

Did you try:


PHP Code:
<?= base_url('my_site/assets/images/');?>



RE: Problem on save image in public directory - PHS - 12-11-2020

(12-11-2020, 01:13 PM)InsiteFX Wrote: It would help if we had a little more information, like what is your base url etc.;

Did you try:


PHP Code:
<?= base_url('my_site/assets/images/');?>

InsiteFX

Thank you for your support!

But I have to apologize for the carelessness on my part, as I checked the PHP settings and the allow_url_fopen directive was not enabled.


RE: [Solved] Problem on save image in public directory - InsiteFX - 12-11-2020

No problem, it's best to always check your php.ini setting's I redo mine from scratch every time
I install a new version.

Glad you figured it out.