move_uploaded_file (newbie error)

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: ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-05-2004
Raj
 
Posts: n/a
Default move_uploaded_file (newbie error)

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>
Reply With Quote
  #2 (permalink)  
Old 06-09-2004
Nathan Gardiner
 
Posts: n/a
Default Re: move_uploaded_file (newbie error)

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



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0