How to use WordPress HTTP API to download file from remote location

Check out download_url() – it’s only loaded in the admin, so you’ll have to include it (or write your own) if needed on the front-end.

From download_url() you can use:

$response = wp_remote_get( 
    TCS_CPDF_REMOTE_ZIP, 
    array( 
        'timeout'  => 300, 
        'stream'   => true, 
        'filename' => TCS_CPDF_LOCAL_ZIP 
    ) 
);

Leave a Comment