Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8343801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:10:26+00:00 2026-06-09T06:10:26+00:00

<?php $top = ../top.txt; $middle = ../middle.txt; $bottom = ../bottom.txt; $end = /st.txt; $data

  • 0
<?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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:10:28+00:00Added an answer on June 9, 2026 at 6:10 am
    $top = "../top.txt";
    

    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:

    $end = "/st.txt";
    $data = "/dt.txt"
    

    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:

    $end = "./st.txt";
    $data = "./dt.txt"
    

    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.php then your files would be linked like:

    $top = "/var/www/httpdocs/top.txt";
    $middle = "/var/www/httpdocs/middle.txt";
    $bottom = "/var/www/httpdocs/bottom.txt";
    
    $end = "/st.txt";
    $data = "/dt.txt"
    

    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:

    $end = "/var/www/httpdocs/project/st.txt";
    $data = "/var/www/httpdocs/project/dt.txt"
    

    Hope this explains it. And yes, do look into the functions other people mentioned in the answers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing web page which has main file index.php as follows: include('UserClass.php'); include('html/top.php'); $user
In PHP switch statements, does placing more common cases near the top improve performance?
I have a php form that has a known number of columns (ex. top
Why wont this work? <?php include top.php; include connect.php; if(isset($_POST[submit])) { $error = ;
I am newer for php. I want make php page cache, query data from
I have an odd issue here :http://alarmefast.com/securitasdirect2011/index.php On the top left corner, I have
As taken from https://stackoverflow.com/questions/4891301/top-bad-practices-in-php Is this similar code killing kittens, too? foreach (file(longFile.txt) as
$j=1; ?> var t =''; var options = ; </script> <?php foreach ($this->data['DEFAULTS'] as
here is the page : http://missfrisette.com/index.php# the top white box, should be 35 pixel
When designing a website I created a top.php page to hold the essence of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.