6 months ago

how to download a remote file without specifying filesize

Posted 6 months ago by danimohamadnejad

Hello I have a file on dl.x.com/v.zip and I have prevented direct access to using .htacces containing "deny from all". now I want to allow users to download file through x.com/download.php using following code: $url='http://dl.x.com/v.zip'; $headers=get_headers($url,true); $filename='ddd'; $filesize=$headers['Content-Length']; header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename=\"".basename($url)."\""); header('Content-Length: '.$filesize); header("Content-Transfer-Encoding: Binary"); header('Content-Type: application/zip'); readfile($url); exit; but I cant use get_headers function to get filesize of remote file. So how can I do this?

Please sign in or create an account to participate in this conversation.