Jump to content


Can't find path

  • Please log in to reply
1 reply to this topic

#1 pog

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 04 September 2006 - 11:02 PM

I have a short script for processing some email addresses. The script contains the following form:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<label for="openedfile">Choose a file:</label>
<input type="file" name="openedfile"><br>
<input type="submit" value="submit"><br>

I have some php in the page that looks like this:
$filename = $_FILES['openedfile']['name'];
$fp = @fopen($filename, "r+") or exit("<br>Could not open file");
$contents .= @fread($fp, filesize($filename)) or exit("<br>Could not read file");

Problem is, it only works if the chosen file is in the same directory as the script. Any other parent- or sub-directory and it says it doesn't exist. I'm guessing this is rrreally simple, but any help much appreciated!

#2 onlyican

  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 04 September 2006 - 11:25 PM

You will need to navigate to it
$filename = mypage.php (same Directory)
$filenam = folder/my2ndpage.php (mypage in a folder called folder)

PHP aint that clever to know you mean go into a folder to look for it
it simply looks where it is
Tell me the problem, I will try tell you the solution

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users