download_url [ WordPress Function ]
download_url ( $url, $timeout = 300 )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Downloads a url to a local temporary file using the WordPress HTTP Class.
Please note, That the calling function must unlink() the file.
Source
<?php
function download_url( $url, $timeout = 300 ) {
//WARNING: The file is not automatically deleted, The script must unlink() the file.
if ( ! $url )
return new WP_Error('http_no_url', __('Invalid URL Provided.'));
$tmpfname = wp_tempnam($url);
if ( ! $tmpfname )
return new WP_Error('http_no_file', __('Could not create Temporary file.'));
$response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
if ( is_wp_error( $response ) ) {
unlink( $tmpfname );
return $response;
}
if ( 200 != wp_remote_retrieve_response_code( $response ) ){
unlink( $tmpfname );
return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
}
return $tmpfname;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- download_url - WordPress Codex
Description. Downloads a url to a local temporary file using the WordPress HTTP Class. Please note, That the calling function must unlink() the file.
codex.wordpress.org - PHPXRef 0.7 : WordPress : Function Reference: download_url()
Function and Method Cross Reference. download_url(). Defined at: /wp-admin/ includes/file.php -> line 467. Referenced 2 times: ...
phpxref.ftwr.co.uk - Access download_url <a> attribute from - Stack Overflow
Chrome contextMenus API doesn't provide you that information. It doesn't tell you what element was clicked. I imagine you can code a workaround, ...
stackoverflow.com - Downloads - pybox2d - 2D Game Physics for Python - Google ...
Filename ▼, Summary + Labels ▼, Uploaded ▼, ReleaseDate ▼, Size ▼, DownloadCount ▼ ... pybox2d-2.0.2b2.zip · pybox2d 2.0.2b2 source (r330) Featured ...
code.google.com