Changeset 5008 for trunk/wp-includes/functions.php
- Timestamp:
- 03/09/2007 08:14:52 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r4990 r5008 1095 1095 } 1096 1096 1097 function wp_upload_bits($name, $type, $bits , $overwrite = false) {1097 function wp_upload_bits($name, $type, $bits) { 1098 1098 if ( empty($name) ) 1099 1099 return array('error' => __("Empty filename")); … … 1123 1123 } 1124 1124 1125 // If we are asked to over write the file then make sure 1126 // the $name has the complete path and is writable. 1127 if($overwrite) { 1128 if(!is_writable($name)) { 1129 return(array("error" => __("Can not over write file."))); 1130 } 1131 $new_file = $name; 1132 $filename = basename($name); 1133 } 1134 else { 1135 $new_file = $upload['path'] . "/$filename"; 1136 if ( ! wp_mkdir_p( dirname($new_file) ) ) { 1137 $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); 1138 return array('error' => $message); 1139 } 1125 $new_file = $upload['path'] . "/$filename"; 1126 if ( ! wp_mkdir_p( dirname($new_file) ) ) { 1127 $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); 1128 return array('error' => $message); 1140 1129 } 1141 1130 … … 1152 1141 @ chmod($new_file, $perms); 1153 1142 1154 // Compute the URL if this is a new file.1143 // Compute the URL 1155 1144 $url = $upload['url'] . "/$filename"; 1156 if($overwrite) {1157 $url = $name;1158 }1159 1145 1160 1146 return array('file' => $new_file, 'url' => $url, 'error' => false);
Note: See TracChangeset
for help on using the changeset viewer.