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);
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?
Asked
Active
Viewed 986 times
0

Li'
- 3,133
- 10
- 34
- 51
-
Is the image directory outside the project directory? – Kneel-Before-ZOD Nov 21 '12 at 05:43
-
img directory is under the project dir – Li' Nov 21 '12 at 05:59
2 Answers
2
Try removing the / at the start of /img/bar.png

James McDonnell
- 3,600
- 1
- 20
- 26
-
Agreed. You are attempting to write relative to the root of the boot disk, not relative to your application. – Joshua Kaiser Nov 21 '12 at 05:48
-
Yep, you could also just prepend a . to your path like so ./img/bar.png – James McDonnell Nov 21 '12 at 05:55
-
-
could you post your file hierarchy starting at the root of your application, and tell us which file this code is in? – James McDonnell Nov 21 '12 at 06:00
-
the code is in the file named barshow.php, path: ~/Applications/XAMPP/xamppfiles/htdocs/Twitter/barshow.php. Twitter dir is the project dir. img dir is also in the Twitter dir: .../Twitter/img – Li' Nov 21 '12 at 06:26
0
Try
$root = $_SERVER["DOCUMENT_ROOT"] . "/img";
$fileName = "$root/bar.png";
Hope this helps.

Kneel-Before-ZOD
- 4,141
- 1
- 24
- 26