简体   繁体   中英

PHP no permission to write to file in MAC

I am using XAMPP(PHP APACHE MYSQL) to develop a program in MAC. When I try to use JPGRAPH to write to file, code: $fileName = "/img/bar.png"; $graph->img->Stream($fileName); $fileName = "/img/bar.png"; $graph->img->Stream($fileName); I got this warning: Cant write to file, check that the process running PHP has enough permission. I searched a lot, and tried many ways: 1.sudo chmod 777 ~/File/Java/img 2.change user name in Apache httpd.conf (default username is nobody) 3.mkdir($create_path, 0777). Still I cant figure it out. Any suggestion?

尝试删除/img/bar.png开头的/

Try


   $root = $_SERVER["DOCUMENT_ROOT"] . "/img";
   $fileName = "$root/bar.png";
 

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM