Problems writing file to server using fopen/file_exists
Posted: Thu Aug 06, 2009 7:01 am
Sorry guys, I have been trying a number of differrent ways to do this but I am now totally confused.
My require is:
1. Check to see if a file exists on a particluar server
2. if it does not then create the file with some contents.
I have read a number of articles about checking safe_mode etc and the server I am using, which is where all the files that I want to write to exists has the following settings:-
allow_url_fopen = On
allow_url_include = Off
file_uploads = On
safe_mode = Off
The server where I am running the script is the same server where I want to write the files to.
So I started to use
$FileToCheck = "http://www.mysite.com/Admin/test.php";
if (!file_exists($FileToCheck)) {echo "File " . $FileToCheck . " Does Not Exists";}
This always returns false even is the file exists.
So I tried another method as follows:
$FileToCheck = "http://www.mysite.com/Admin/test.php";
if($handle = fopen($FileToCheck, 'x+')) {echo "File Opened OK</br>";}
This always returns true even if the file does not exist.
So now I am confused and need some help on whether I need to check other php.ini setting or
why file_exists and fopen are not doing what I am expecting
Thanks in Advance.
My require is:
1. Check to see if a file exists on a particluar server
2. if it does not then create the file with some contents.
I have read a number of articles about checking safe_mode etc and the server I am using, which is where all the files that I want to write to exists has the following settings:-
allow_url_fopen = On
allow_url_include = Off
file_uploads = On
safe_mode = Off
The server where I am running the script is the same server where I want to write the files to.
So I started to use
$FileToCheck = "http://www.mysite.com/Admin/test.php";
if (!file_exists($FileToCheck)) {echo "File " . $FileToCheck . " Does Not Exists";}
This always returns false even is the file exists.
So I tried another method as follows:
$FileToCheck = "http://www.mysite.com/Admin/test.php";
if($handle = fopen($FileToCheck, 'x+')) {echo "File Opened OK</br>";}
This always returns true even if the file does not exist.
So now I am confused and need some help on whether I need to check other php.ini setting or
why file_exists and fopen are not doing what I am expecting
Thanks in Advance.