Changeset 4961 for trunk/wp-includes/functions.php
- Timestamp:
- 03/03/2007 04:56:46 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r4951 r4961 1116 1116 else 1117 1117 $ext = ".$ext"; 1118 while ( file_exists($upload['path'] . "/$filename") && !$overwrite) {1118 while ( file_exists($upload['path'] . "/$filename") ) { 1119 1119 if ( '' == "$number$ext" ) 1120 1120 $filename = $filename . ++$number . $ext; … … 1123 1123 } 1124 1124 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); 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 } 1129 1140 } 1130 1141 … … 1141 1152 @ chmod($new_file, $perms); 1142 1153 1143 // Compute the URL 1154 // Compute the URL if this is a new file. 1144 1155 $url = $upload['url'] . "/$filename"; 1156 if($overwrite) { 1157 $url = $name; 1158 } 1145 1159 1146 1160 return array('file' => $new_file, 'url' => $url, 'error' => false);
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)