<?php
$top = "../top.txt";
$middle = "../middle.txt";
$bottom = "../bottom.txt";
$end = "/st.txt";
$data = "/dt.txt";
$handle1 = fopen($top, "r");
$contents1 = fread($handle1, filesize($top));
fclose($handle1);
$handle2 = fopen($end, "r");
$contents2 = fread($handle2, filesize($end));
fclose($handle2);
$handle3 = fopen($middle, "r");
$contents3 = fread($handle3, filesize($middle));
fclose($handle3);
$handle4 = fopen($data, "r");
$contents4 = fread($handle4, filesize($data));
fclose($handle4);
$handle5 = fopen($bottom, "r");
$contents5 = fread($handle5, filesize($bottom));
fclose($handle5);
echo $contents1;
echo $contents2;
echo $contents3;
echo $contents4;
echo $contents5;
?>
I get these errors for every one of them:
Warning: fopen(../top.txt) [function.fopen]: failed to open stream: No such file or directory
Warning: filesize() [function.filesize]: stat failed for ../top.txt
Warning: fread(): supplied argument is not a valid stream resource
Warning: fclose(): supplied argument is not a valid stream resource
CHMOD in all files and folders and is set to 777
All the files exist on the server
PHP5 is installed on the server
What am i doing wrong?
means that from your current position it moves one folder up, and searches for the file
top.txt. It’s same for$middle = "../middle.txt";and$bottom = "../bottom.txt";. For these two:it’s searching from the root directory. Do make sure you have the files located at the places you refer them to. I may think you wanted this in the last two variables:
Where
./represents the current directory.So, to give you more detailed example. Lets say you have your PHP file located at
/var/www/httpdocs/project/phpFile.phpthen your files would be linked like:So now notice the difference in the last two variables – they stay the same, because you’ve set it to be looking from root directory (
/). Where as if you would use the linking with./, then the paths would be:Hope this explains it. And yes, do look into the functions other people mentioned in the answers.