Make WordPress Core


Ignore:
Timestamp:
03/03/2007 04:56:46 PM (20 years ago)
Author:
ryan
Message:

xmlrpc updates from Joseph Scott.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r4951 r4961  
    11161116        else
    11171117                $ext = ".$ext";
    1118         while ( file_exists($upload['path'] . "/$filename") && !$overwrite ) {
     1118        while ( file_exists($upload['path'] . "/$filename") ) {
    11191119                if ( '' == "$number$ext" )
    11201120                        $filename = $filename . ++$number . $ext;
    … …  
    11231123        }
    11241124
    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                }
    11291140        }
    11301141
    … …  
    11411152        @ chmod($new_file, $perms);
    11421153
    1143         // Compute the URL
     1154        // Compute the URL if this is a new file.
    11441155        $url = $upload['url'] . "/$filename";
     1156        if($overwrite) {
     1157                $url = $name;
     1158        }
    11451159
    11461160        return array('file' => $new_file, 'url' => $url, 'error' => false);
Note: See TracChangeset for help on using the changeset viewer.