summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-includes/functions-post.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-12-03 13:49:00 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-12-03 13:49:00 +0000
commitfba798a103256f5f400cb1a1dcb9cc5b45cf8166 (patch)
treec3855c768b2e80ff237fb92101285733277f96c5 /wp-inst/wp-includes/functions-post.php
parent5133ce3a39180e0fa922a1d403224f5650089d95 (diff)
downloadwordpress-mu-fba798a103256f5f400cb1a1dcb9cc5b45cf8166.tar.gz
wordpress-mu-fba798a103256f5f400cb1a1dcb9cc5b45cf8166.tar.xz
wordpress-mu-fba798a103256f5f400cb1a1dcb9cc5b45cf8166.zip
WP Merge and misc fixes, worth upgrading for!
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@460 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/functions-post.php')
-rw-r--r--wp-inst/wp-includes/functions-post.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/wp-inst/wp-includes/functions-post.php b/wp-inst/wp-includes/functions-post.php
index c4205cb..38c1cfe 100644
--- a/wp-inst/wp-includes/functions-post.php
+++ b/wp-inst/wp-includes/functions-post.php
@@ -778,4 +778,37 @@ function get_post_mime_type($ID = '') {
function get_attached_file($attachment_id) {
return get_post_meta($attachment_id, '_wp_attached_file', true);
}
+
+function wp_upload_bits($name, $type, $bits) {
+ if ( empty($name) )
+ return array('error' => "Empty filename");
+
+ $upload = wp_upload_dir();
+
+ if ( $upload['error'] !== false )
+ return $upload;
+
+ $number = '';
+ $filename = $name;
+ while ( file_exists($upload['path'] . "/$filename") )
+ $filename = str_replace("$number.$ext", ++$number . ".$ext", $filename);
+
+ $new_file = $uploads['path'] . "/$filename";
+ $ifp = @ fopen($new_file, 'wb');
+ if ( ! $ifp )
+ return array('error' => "Could not write file $new_file.");
+
+ $success = @ fwrite($ifp, $bits);
+ fclose($ifp);
+ // Set correct file permissions
+ $stat = @ stat(dirname($new_file));
+ $perms = $stat['mode'] & 0000777;
+ @ chmod($new_file, $perms);
+
+ // Compute the URL
+ $url = $upload['url'] . "/$filename";
+
+ return array('file' => $new_file, 'url' => $url);
+}
+
?>