DeveloperSide.NET Forums

DeveloperSide.NET => Anything else goes here => Topic started by: portland on March 27, 2007, 02:40:33 PM



Title: strange upload error
Post by: portland on March 27, 2007, 02:40:33 PM
When I upload a file (eg f00.jpg), and execute move_uploded file, it is moved to Apache\f00.jpg and NOT to the specified dir.

When I upload the same file again, it DOES move the file to the right directory.

In both cases move_uploaded_file returns 'true'.

It looks like the file is only placed in the proper directory when no fo file of that name exists in Apache\ (I tried that).

Looks like a bug.  Or?

Code:
   <form action="" method="POST" enctype="multipart/form-data">
   <input class="b" name="upload" type="file" size="40">&nbsp;&nbsp;
   <input class="b" type="submit" value="Upload">

and on upload:

   switch(true)
   {
   case $_FILES['upload']['name']=='':
      echo 'No file for upload!';
      return false;
   break;

   default:
      $fileSaveName=$_FILES['upload']['name'];
      
      if(move_uploaded_file($_FILES['upload']['tmp_name'],$fileSaveName))
      {
       echo 'Move OK: '.$path.$fileSaveName; // debug
         return $fileSaveName;
      }
      else
      {
       echo 'Move BAD'.$path.$fileSaveName; // debug
         return false;
      }
   break;
   }