Topic: [pun_attachment] Fix file upload without parent directory

Currently file upload fails if $forum_config['attach_basefolder'] exists and is writable, but $forum_config['attach_subfolder'] does not.

This patch fixes that.

--- include/attach_func.php.orig    2011-08-10 12:28:07.000000000 +0300
+++ include/attach_func.php    2011-08-10 12:29:24.000000000 +0300
@@ -120,7 +120,13 @@
         if (is_uploaded_file($uploaded_file['tmp_name']) )
         {        
             $attach_name = attach_generate_filename();
-            if (!move_uploaded_file($uploaded_file['tmp_name'], $forum_config['attach_basefolder'].$forum_config['attach_subfolder'].'/'.$attach_name))
+            $destination = $forum_config['attach_basefolder'].
+                $forum_config['attach_subfolder'].'/'.$attach_name;
+            // Ensure base directory exists, because otherwise move_uploaded_file()
+            // fails
+            mkdir(dirname($destination), 0755, true);
+            
+            if (!move_uploaded_file($uploaded_file['tmp_name'], $destination))
                 $errors[] = sprintf($lang_profile['Move failed'], '<a href="mailto:'.forum_htmlencode($forum_config['o_admin_email']).'">'.forum_htmlencode($forum_config['o_admin_email']).'</a>');
             if (empty($errors))
             {

Re: [pun_attachment] Fix file upload without parent directory

Ok, i check this.

Thanks for report.