Jump to content

What does this error mean?


Dryan

Recommended Posts

I added error_reporting(E_ALL); to the top of my .php file, and now it's returning this error:

 

Warning: move_uploaded_file(/upload/tuffy-20071106.zip) [function.move-uploaded-file]: failed to open stream: No such file or directory in /homepages/28/d93538065/htdocs/library2/upload_file.php on line 24

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpw9MELL' to '/upload/tuffy-20071106.zip' in /homepages/28/d93538065/htdocs/library2/upload_file.php on line 24

Stored in: upload/tuffy-20071106.zip

 

 

Here's my php code:

 

<?php
error_reporting(E_ALL);
if (($_FILES["file"]["type"] == "application/zip")
&& ($_FILES["file"]["size"] < 10000000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }

Link to comment
https://forums.phpfreaks.com/topic/186813-what-does-this-error-mean/
Share on other sites

Change this

if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);

 

to

$upload_path = dirname(__FILE__) . '/upload/';
if (file_exists($upload_path . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
       move_uploaded_file($_FILES["file"]["tmp_name"], $upload_path . $_FILES["file"]["name"]);

I get this error when I try that:

 

Warning: move_uploaded_file(/homepages/28/d93538065/htdocs/library2/upload/tuffy-20071106.zip) [function.move-uploaded-file]: failed to open stream: No such file or directory in /homepages/28/d93538065/htdocs/library2/upload_file.php on line 24

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phptmLl8g' to '/homepages/28/d93538065/htdocs/library2/upload/tuffy-20071106.zip' in /homepages/28/d93538065/htdocs/library2/upload_file.php on line 24

Stored in: upload/tuffy-20071106.zip

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.