From fce486c48ce63f52fdbe1e555a8c4be35be9e2bc Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 2 Jan 2006 04:59:39 +0000 Subject: [PATCH] Create dir hierarchy for files passed to wp_upload_bits(). git-svn-id: https://develop.svn.wordpress.org/trunk@3390 602fd350-edb4-49c9-b593-d223f7449a82 --- 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 a37ea6dccf..12b2d6850c 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.");