downloading - What's the best way to supply download of a digital product in PHP? -


Digital business products that pay for customer download links.

I downloaded all zip files (products) outside the web document route and buyer via a PHP script which is integrated from PayPal IPN to ensure that the downloader is a payee.

Like this way:

So far, all this works only with a problem. The ZIP file downloaded through the above URL is corrupted and it is compatible with WinRAR Not open can. However, the downloaded zip is OK.

My code:

  $ path = WAREHOUSE_PATH. '/ Products /' $ Identifier '. Zip '; $ Mm_type = "application / octet stream"; Header ("PAGMA: public"); Header ("End: 0"); Header ("Cash-Control: Required-Modified, Post Check = 0, Pre-Check = 0"); Header ("cache-control: public"); Header ("content-description: file transfer"); Header ("Content-Type:". $ Mm_type); Header ("content-length:". (String) (filesystem ($ path)); Header ('content-dispute: attachment; filename =' '. Bassname ($ path).' '' '); Header ("Content-Transfer-Encoding: Binary \ n"); $ Fp = @ fopen ($ path, "rb"); If ($ FP) {while (FIF ($ FP)} {print (FRED ($ FP, 1024 * 8)); flush (); if (connection_status ()! = 0) {@fclose ($ fp) ; Die ();}} @ feklos ($ FP);}  

What could be wrong? Thanks!

Problem Solving: For Everyone Thanks, it has been found that there are some extra white spaces in the downloaded package that should not be there. Idiot.

You will be better off using Bus unless you do ignore_user_abort Then, the script will end automatically if the user cancels.

If you are still having problems, then load the file in hex editor and the first few letters and last few letters. < / P>


Comments