DeveloperSide.NET Forums
December 12, 2019, 08:13:51 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: strange upload error  (Read 4417 times)
0 Members and 1 Guest are viewing this topic.
portland
Jr. Member
**
Posts: 32


View Profile
« 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;
   }
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!