PDA

View Full Version : cannot open file


begeiste
09-14-2007, 01:23 AM
Hi,

Not sure where area I have messed up the php codes? I have put the newvideonettable.htm in the Macintosh HD://Applications/MAMP/htdocs/lessons/, when I called it that shows me Can not open this file!

Your tip will be much appreciated!

<?php



//pointing file in my desktop

$file1="Macintosh HD://Applications/MAMP/htdocs/lessons/newvideonettable.htm";

//read only pointing to file

$re_file1=@fopen($file1,"r");



//determining file1 whether sucessfully open(return value whether is !=0)

if($re_file1!=0){

//reading file

$content=fread($re_file,100);

//displaying content

echo "below is action_post.php content: <p>";

echo $content."<p>";



//closing file

$ret=fclose($re_file1);



//determine file whether is opened

if($ret==True){

echo "File has been correctly opened...";

}else{

echo "File has been not opened correctly...";

}

}else{

echo "Can not open this file!";

}

?>

PremiumBlend
09-14-2007, 02:42 AM
Are you just trying to display the file? You can do it like so:


$fileToShow = "Macintosh HD://Applications/MAMP/htdocs/lessons/newvideonettable.htm";
if (is_file($fileToShow)) {
include_once($fileToShow);
} else {
echo '<strong>Invalid File.</strong>' . "\n";
}

begeiste
09-14-2007, 06:29 PM
Much appreciated your help!!