This is a discussion on move_uploaded_file (newbie error) within the PHP Language forums, part of the PHP Programming Forums category; Hi, I get the following errors when I try to use the file below. Any ideas. Raj Newbie ERRORS: Warning: ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi, I get the following errors when I try to use the file below. Any
ideas. Raj Newbie ERRORS: Warning: move_uploaded_file(../uploads/ok.jpg): failed to open stream: No such file or directory in /www/webdir/test/upload_file.php on line 11 Warning: move_uploaded_file(): Unable to move '/tmp/phpVnaunp' to '../uploads/ok.jpg' in /www/webdir/test/upload_file.php on line 11 THE FILE "upload_file.php": <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php ini_set ('display_errors',1); error_reporting (E_ALL & ~E_NOTICE); if (isset ($_POST['submit'])){ if (move_uploaded_file ($_FILES['thefile']['tmp_name'], "../uploads/{$_FILES['thefile']['name']}")){ print '<p>Your file has been uploaded.</p>'; } else{ print '<p>Your file could not be uploaded<b>'; } } ?> <form action="upload_file.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <input type="file" name="thefile" /><br/><br /> <input type="submit" name="submit" value="Upload this file" /> </form> </body> </html> |
|
|||
|
Raj wrote:
> Hi, I get the following errors when I try to use the file below. Any > ideas. > > Raj > Newbie > > ERRORS: > > Warning: move_uploaded_file(../uploads/ok.jpg): failed to open stream: > No such file or directory in /www/webdir/test/upload_file.php on line > 11 > > Warning: move_uploaded_file(): Unable to move '/tmp/phpVnaunp' to > '../uploads/ok.jpg' in /www/webdir/test/upload_file.php on line 11 > > > > THE FILE "upload_file.php": > > <html> > <head> > <title>Untitled Document</title> > <meta http-equiv="Content-Type" content="text/html; > charset=iso-8859-1"> > </head> > <body> > <?php > ini_set ('display_errors',1); > error_reporting (E_ALL & ~E_NOTICE); > if (isset ($_POST['submit'])){ > if (move_uploaded_file ($_FILES['thefile']['tmp_name'], > "../uploads/{$_FILES['thefile']['name']}")){ > print '<p>Your file has been uploaded.</p>'; > } else{ > print '<p>Your file could not be uploaded<b>'; > } > } >> > <form action="upload_file.php" enctype="multipart/form-data" > method="post"> > <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> > <input type="file" name="thefile" /><br/><br /> > <input type="submit" name="submit" value="Upload this file" /> > </form> > </body> > </html> Raj, This is due to the relative path you have used (../uploads/). I would recommend using an absolute path for this, or at least determining that you are infact using the working directory your script assumes you are. Nathan |