php - How to read file from another FTP host without use host bandwidth transfer -


i have host store data , download host (this host doesn't have database). want read file download host in store host , give user download don't want use monthly bandwidth transfer of store host when user downloading file , use download host bandwidth transfer.

there 2 ways know:

  1. ftp_get download file , save in local file , set header download. don't want use way because download file in store host.

    // in store host $local_file = 'app.apk'; $ftp_file = '/uploads/2015/06/1eb6a628c60bb69a6b6092d03e252c29.apk'; // download file , save in local ftp_get($conn_id , $local_file, $ftp_file, ftp_binary);  $file_name = 'app.apk'; $file_size = filesize($local_file);  header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename=' . $file_name); header('content-transfer-encoding: binary'); header('connection: keep-alive'); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('pragma: public'); header('content-length: ' . $file_size);  readfile($local_file); 
  2. i don't know file_get_contents use bandwidth transfer of store host when user downloading file or not.

    // in store host header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename=' . $file_name); header('content-transfer-encoding: binary'); header('connection: keep-alive'); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('pragma: public'); header('content-length: ' . $file_size);  // readfile($local_file);  $c = file_get_contents('ftp://login:pass@download-host.com/uploads/2015/06/app.apk'); echo $c; 

i don't want use bandwidth transfer in store host; way can use? way 2 or way?

there's no way download contents "download host" directly client, without providing client information needed download ("download link").

if need hide download information client, need download file on "store host" , forward client. hence consuming bandwidth data of "store host". not matter technology, protocol or function use. , ftp_get , file_get_contents("ftp://...") use both same code behind anyway.

simply said, there's no way both hide download information client , not use bandwidth data of "store host".


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -