0
votes

I took this basic upload file script from php.net and it is giving two warning before it move the image to the directory.

Warning: move_uploaded_file(public_html/your/inventory_images/penguin.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home3/ny/public_html/your/anotherformsale.php on line 73

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpnIxYMK' to 'public_html/your/inventory_images/penguin.jpg' in /home3/ny/public_html/your/anotherformsale.php on line 73

I am getting this warning after I have tried to upload a image with a basic move_upload script below.

 <?php    
  $uploaddir ='public_html/your/inventory_images/';//<----This is all I
     changed $uploadfile = $uploaddir . basename($_FILES['file']['name']);

     echo '<pre>'; if (move_uploaded_file($_FILES['file']['tmp_name'],
     $uploadfile)) {
         echo "File is valid, and was successfully uploaded.\n"; } else {
         echo "Possible file upload attack!\n"; }

     echo 'Here is some more debugging info:'; print_r($_FILES);

     print "</pre>"; 
 ?>
2
Does the folder public_html/your/inventory_images exist as relative path to the .php? - PtPazuzu
@PtPazuzu I have the file anotherformsale.php inside your folder and inside your folder I have inventory_images folder where I want to move or save the upload. - user841823

2 Answers

2
votes

According to warning message(No such file or directory in /home3/ny/public_html/your/anotherformsale.php on line 73) the path you are using is wrong.

it should be set to

$uploaddir ='/home3/ny/public_html/your/inventory_images/';

After confirmation of path you should also make sure the destination directory is writable.

0
votes

If you read the warning you can see :

  • the destination directory does not exist

    or

  • you haven't set the correct file permission on it

To solve it check the path, permission, etc...