Rollback previous patch to compose.php because it breaks more than it
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 15 Jan 2003 12:31:33 +0000 (12:31 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 15 Jan 2003 12:31:33 +0000 (12:31 +0000)
fixes. However, we should prefer using move_uploaded_file over rename
because move_uploaded_file works better with safe_mode/open_basedir
restrictions. Not doing that now because we're in rc phase.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4420 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/compose.php

index fd7e07cc1ea25c3290a70cd5dd10ef8f010891ff..fef9c415234caa710a3d87def48a1651e2977d1d 100644 (file)
@@ -1176,10 +1176,13 @@ function saveAttachedFiles($session) {
         $full_localfilename = "$hashed_attachment_dir/$localfilename";
     }
 
         $full_localfilename = "$hashed_attachment_dir/$localfilename";
     }
 
-    if (!@move_uploaded_file($_FILES['attachfile']['tmp_name'],$full_localfilename)) {
-        return true;
+    // FIXME: we SHOULD prefer move_uploaded_file over rename because
+    // m_u_f works better with restricted PHP installes (safe_mode, open_basedir)
+    if (!@rename($_FILES['attachfile']['tmp_name'], $full_localfilename)) {
+            if (!@move_uploaded_file($_FILES['attachfile']['tmp_name'],$full_localfilename)) {
+               return true;
+           }
     }
     }
-
     $message = $compose_messages[$session];
     $type = strtolower($_FILES['attachfile']['type']);
     $name = $_FILES['attachfile']['name'];
     $message = $compose_messages[$session];
     $type = strtolower($_FILES['attachfile']['type']);
     $name = $_FILES['attachfile']['name'];