Forum Moderators: coopster

Message Too Old, No Replies

fopen problem

         

fabiox

5:01 pm on Apr 28, 2005 (gmt 0)

10+ Year Member



Hi,
See this code:
$PATH=$DOCUMENT_ROOT."close/texto.txt";
$PATH2=$DOCUMENT_ROOT."close/06_vid.jpg";
print $PATH;
$fp=fopen($PATH2,'rb');

Line $PATH works and other($PATH2 with image) not works.
help..

ironik

10:04 pm on Apr 28, 2005 (gmt 0)

10+ Year Member



Any reason your trying to open an image file? Usually if you want to modify and image in some way you'll be wanting the GD library functions. Can you post the error you are getting?

fabiox

2:19 am on Apr 29, 2005 (gmt 0)

10+ Year Member



It is under of .htaccess.
The file .htaccess redirect for this script when in end of URL have .gif or .jpg.

php_value session.gc_maxlifetime 36000
php_value register_globals on
php_value max_execution_time 600
php_value allow_url_fopen On
php_value display_errors off
php_value display_startup_errors off

RewriteEngine on
RewriteRule ^(.+)\.(gif¦jpg)$ system/redirect.php

If i remove .htaccess works the fopen. But text file works with or without .htaccess.
I'm confused. Can to be permissions,apache,config of PHP.
Ideas,solution? :-)

ironik

2:41 am on Apr 29, 2005 (gmt 0)

10+ Year Member



That would be it, I think fopen is kind of like a wrapper to the servers (or operating systems?) protocol handling functions (treats the variable passed in the function as a URL). In your case it is obeying the .htaccess directive and being pushed to the redirect script. It's treated exactly the same way as if the file was being accessed via URL.

Here's a speil from the manual:


fopen() binds a named resource, specified by filename, to a stream. If filename is of the form "scheme://...", it is assumed to be a URL and PHP will search for a protocol handler (also known as a wrapper) for that scheme. If no wrappers for that protocol are registered, PHP will emit a notice to help you track potential problems in your script and then continue as though filename specifies a regular file.

Maybe someone has a suggestion of getting around your problem... mine would be to ditch the current rewrite rule in favour of something that will permit your script to access the file (can't help you on that one unfortunately).

coopster

12:58 am on May 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Looks like this one was solved [webmasterworld.com] in the Apache Forum.

Glad you got it sorted, fabiox ;)

fabiox

8:21 pm on May 6, 2005 (gmt 0)

10+ Year Member



for this problem (fopen) i used the function file_get_contents and works. :)