pog Posted September 4, 2006 Share Posted September 4, 2006 Hi,I have a short script for processing some email addresses. The script contains the following form:[code]<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></form>[/code]I have some php in the page that looks like this:[code]$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");fclose($fp);[/code]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! Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 4, 2006 Share Posted September 4, 2006 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 itit simply looks where it is Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.