I have a WordPress site A and send zip file with PHP-X-Sendfile, for example:
https://a.com/?download=a will download file a.zip[
if (!empty($_GET['download'])) {
$xSendFile = new PhpXsendfile();
$xSendFile->download(WP_CONTENT_DIR . '/a.zip');
}
it's working perfectly.
and now I want to download it from WordPress site B. for example:
https://b.com/?download=a can download file from https://a.com/?download=a.
I tried methods below:
Method 1:
$file_url = 'https://a.com/?download=a';
$a = download_url($file_url, 3000);
die;
Result: Not working, and return WP_Error A valid URL was not provided.
Note: download_url is a built-in WordPress function for download external file.
Method 2:
$file_url = 'https://a.com/?download=a';
$xSendFile = new PhpXsendfile();
$xSendFile->download($file_url);`
Result: Not working, and got browser error 'This site can’t be reached'.
So I think the problem is how to download remote file send by X-sendfile?
Any ideas? thank you.