PHP Classes

Path setting for image storage

Recommend this page to a friend!

      CAPTCHA 2  >  All threads  >  Path setting for image storage  >  (Un) Subscribe thread alerts  
Subject:Path setting for image storage
Summary:Is there is a conflict between real path and document root?
Messages:2
Author:Brandon Sussman
Date:2007-02-28 19:03:46
Update:2007-03-01 06:00:08
 

  1. Path setting for image storage   Reply   Report abuse  
Picture of Brandon Sussman Brandon Sussman - 2007-02-28 19:03:46
To reproduce, put /captcha2 and its contents into web root dir, make example.php work correctly, move example.php one level up, make it work.

I moved example.php 1 level up from /captcha2/ so it is in my web document root dir.

This is in the class file, in /captcha2 :

private $font_size = 24; // if GD2 in points / GD1 in pixels
private $font = '/captcha2/arial.ttf';
private $img_height = 70;
private $save_path = '/home/xxxx/www/www/captcha2/gdtest';

/home/xxxx/www/www is the document root for the web space.

I get alt text instead of the generated png - the image uri contains the whole real path to gdtest which is incorrect. The file is actually generated - I prove by looking directly at it.

if I change save_path to '/captcha2/gdtest' I get error "Unable to open '/captcha2/gdtest/xxxxx.png' for writing."

  2. Re: Path setting for image storage   Reply   Report abuse  
Picture of Cristian Navalici Cristian Navalici - 2007-03-01 06:00:08 - In reply to message 1 from Brandon Sussman
Hello,

So you have captcha2 folder in web root dir and example.php in the same place (1 level up from captcha).

Your font is in captcha dir I assume. Try to change:

private $font = '/captcha2/arial.ttf';

to

private $font = '/home/xxxx/www/www/captcha2/arial.ttf';

or

private $font = 'captcha2/arial.ttf'; // without beginning slash.

Tell if you still have this error.
Regards.