Changeset 7547 for trunk/wp-admin/includes/file.php
- Timestamp:
- 03/27/2008 07:36:30 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/file.php
r7414 r7547 193 193 * 194 194 * @param string $url the URL of the file to download 195 * @return mixed falseon failure, string Filename on success.195 * @return mixed WP_Error on failure, string Filename on success. 196 196 */ 197 197 function download_url( $url ) { 198 198 //WARNING: The file is not automatically deleted, The script must unlink() the file. 199 199 if( ! $url ) 200 return false;200 return new WP_Error('http_no_url', __('Invalid URL Provided')); 201 201 202 202 $tmpfname = tempnam(get_temp_dir(), 'wpupdate'); 203 203 if( ! $tmpfname ) 204 return false;204 return new WP_Error('http_no_file', __('Could not create Temporary file')); 205 205 206 206 $handle = @fopen($tmpfname, 'w'); 207 207 if( ! $handle ) 208 return false;208 return new WP_Error('http_no_file', __('Could not create Temporary file')); 209 209 210 210 require_once( ABSPATH . 'wp-includes/class-snoopy.php' ); … … 212 212 $snoopy->fetch($url); 213 213 214 if( $snoopy->status != '200' ){ 215 fclose($handle); 216 unlink($tmpfname); 217 return new WP_Error('http_404', trim($snoopy->response_code)); 218 } 214 219 fwrite($handle, $snoopy->results); 215 220 fclose($handle);
Note: See TracChangeset
for help on using the changeset viewer.