From b0f69e20a309841702f8bc0c3cc276332dd9374e Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 2 Jan 2006 04:59:39 +0000 Subject: [PATCH] Create dir hierarchy for files passed to wp_upload_bits(). git-svn-id: http://svn.automattic.com/wordpress/trunk@3390 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-post.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index a37ea6dcc..12b2d6850 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -940,6 +940,11 @@ function wp_upload_bits($name, $type, $bits) { } $new_file = $upload['path'] . "/$filename"; + if ( ! wp_mkdir_p( dirname($new_file) ) ) { + $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); + return array('error' => $message); + } + $ifp = @ fopen($new_file, 'wb'); if ( ! $ifp ) return array('error' => "Could not write file $new_file.");