Rathamon Posted January 8, 2003 Share Posted January 8, 2003 When I use a Webform with a php script to upload a file I have suddenly started to get the following error Warning: Unable to open 'none' for reading: No such file or directory in /home/web/public_html/forum/admin/map.php on line 6 what does this mean? the file/directory DOES exist and I've set the permissions :cry: Link to comment Share on other sites More sharing options...
0 Quboid Posted January 8, 2003 Share Posted January 8, 2003 What is the file you want opened called? By the looks of that, there is an error and it's not getting the relevant filename parameter. Copy and paste the code please. Link to comment Share on other sites More sharing options...
0 Rathamon Posted January 8, 2003 Author Share Posted January 8, 2003 <?php echo "Upload Exhibition layout map<br>"; if ($userfile) { copy($userfile , "/home/web/public_html/forum/layoutphotos/$forum"); } echo "<img src=/forum/layoutphotos/$forum>"; echo "<form enctype=multipart/form-data action=layoutmap.php?forum=$forum method=post>"; ?> <input type="hidden" name="MAX_FILE_SIZE" value="10000"> <input name="userfile" type="file"> <input type = submit value="upload"> </form> <br><a href="index.php">Back to forum admin</a> Link to comment Share on other sites More sharing options...
0 Quboid Posted January 8, 2003 Share Posted January 8, 2003 I presume it's the copy line that fails? The only thing I can see that could be wrong is that that file doesn't exist. Are you sure it exists? How did you check? The if statement won't check if the file exists, it will just check the variable has a value. Try printing the variable to check it holds what you think it holds. Another method to ensure it's not just a missing file is to use the file_exists function before the copy: <?php echo "Upload Exhibition layout map<br>"; if ($userfile) { ?if (file_exists($username)) ? ?copy($userfile , "/home/web/public_html/forum/layoutphotos/$forum"); ?else ? ?print "Error: File missing ($username)<br />"; } echo "<img src=/forum/layoutphotos/$forum>"; echo "<form enctype=multipart/form-data action=layoutmap.php?forum=$forum method=post>"; ?> <input type="hidden" name="MAX_FILE_SIZE" value="10000"> <input name="userfile" type="file"> <input type = submit value="upload"> </form> <br><a href="index.php">Back to forum admin</a> Also, check all permissions, not just on file but on the directory it's in too - and remember, it won't be you trying to access it, it will be the web server, so make sure all people can read it. chmod 644 should do it if it's a *nix server. Link to comment Share on other sites More sharing options...
0 Rathamon Posted January 8, 2003 Author Share Posted January 8, 2003 the file exists and is chmoded to 777 :( Link to comment Share on other sites More sharing options...
0 Quboid Posted January 8, 2003 Share Posted January 8, 2003 What about the directory's permissions? Does the file_exist function find the file? Please try to give as much info as you can. Link to comment Share on other sites More sharing options...
0 Rathamon Posted January 9, 2003 Author Share Posted January 9, 2003 Error: File missing () It always gives that error message permissions are set like this mcug:/home/web/public_html/forum # ls -l total 16 drwxrwxrwx 4 web users 4096 Jan 7 12:29 . drwxr-xr-x 13 web users 4096 Jan 8 18:20 .. drwxr-xr-x 2 web users 4096 Jan 6 17:24 admin drwxrwxrwx 2 web users 4096 Jan 8 17:51 layoutphotos mcug:/home/web/public_html/forum # cd layoutphotos mcug:/home/web/public_html/forum/layoutphotos # ls -l total 8 drwxrwxrwx 2 web users 4096 Jan 8 17:51 . drwxrwxrwx 4 web users 4096 Jan 7 12:29 .. -rwxrwxrwx 1 root root 0 Jan 8 17:51 1 mcug:/home/web/public_html/forum/layoutphotos # and forum = 1 in this test Link to comment Share on other sites More sharing options...
0 Rathamon Posted January 9, 2003 Author Share Posted January 9, 2003 oh in your script you subbed $userfile for $username in some places... I fixed this and get the following error instead now Error: File missing (none) Link to comment Share on other sites More sharing options...
0 Quboid Posted January 9, 2003 Share Posted January 9, 2003 Opps, sorry. A reado, if such a thing exists. The "none" inside the brackets is it printing out the file name it has (assuming you changed my mistake there too, which it looks like you did). Is this what the file is supposed to be called? That file isn't in the layoutphotos directory - the only file I see there is called "1". By the looks of it, somewhere the file name you store in the $userfile variable gets lost or changed. How to you get this? Does this work on a different server? Is this variable passed from the user via a form? If so, try inserting the line $userfile = $_request['userfile']; after the echo line and before the first if statement. This will ensure the script gets the variable passed to it from a form, url-string or cookie. BTW, the permissions look fine. EDIT: Shouldn't there be a ; at the end of your sig? :D :rolleyes: Link to comment Share on other sites More sharing options...
0 Cubano Posted January 9, 2003 Share Posted January 9, 2003 Rathamon, what version of PHP are you using? After PHP 4.2 register globals is turned off by default, so the POST and GET variables have to be accessed through their associative arrays. try $_POST['userfile'] instead and see if that works. Link to comment Share on other sites More sharing options...
0 Rathamon Posted January 10, 2003 Author Share Posted January 10, 2003 PHP 4.1.2 the latest version that I've found to actually work properly with my apache setup.... Anyway I actually fixed the problem now, so thanks for the help :) Link to comment Share on other sites More sharing options...
0 Quboid Posted January 10, 2003 Share Posted January 10, 2003 What was the problem? Glad to hear it's sorted. Link to comment Share on other sites More sharing options...
0 Rathamon Posted January 10, 2003 Author Share Posted January 10, 2003 im not 100% sure! but a complete rewrite of the code seemed to do the trick Link to comment Share on other sites More sharing options...
Question
Rathamon
When I use a Webform with a php script to upload a file I have suddenly started to get the following error
Warning: Unable to open 'none' for reading: No such file or directory in /home/web/public_html/forum/admin/map.php on line 6
what does this mean?
the file/directory DOES exist and I've set the permissions :cry:
Link to comment
Share on other sites
12 answers to this question
Recommended Posts