Page 1 of 1

fopen is not working

Posted: Mon May 12, 2008 12:06 am
by Amresh.Dash
hello everybody,
Pls go through the code below:-

$myOriginFile = "findchip/findchip_to_replace.html";
$myDestinationFile = "findchip/findchip_category" . rand() . ".html";
if (file_exists($myDestinationFile))
{
unlink($myDestinationFile);
}
$fh = fopen($myOriginFile, "w") or die("can't open file");
fwrite($fh, $myLine1);
fclose($fh);
While executing this code in my localhost its working fine but after hosting it to my web server its not working. The output it showing is - can't open file.
Any suggestions from anybody to get it rectified.

Re: fopen is not working

Posted: Mon May 12, 2008 4:48 am
by prashantAG
do the following any one gave u soln
1.check the correct path before hosting, i.e. fopen()
2. in u r code file don't include header(),location("") function.you better to use redirect .
3. gave full path like fopen("c:mydoc\findchip\findchip_to_replace.html")