php - Force download working, but showing invalid when trying to open locally -


I have written this function and by the time I try to open the downloaded copy, everything is well Works and shows that the file is invalid. Here's my job


  function download_file () {// Check for download request: if (isset ($ _GET [' File ']) // Make sure that there is one if the IE is required (if_file ($-> path.basename ($ _GET [' file '])) // // below (ii_get ('Zlib.output_compression')) {ini_set ('Zlib.output_compressi On ',' off '); } // set header: header ('PGM: public'); Header ('expiration: 0'); Header ('Cash-Control: Required-Modified, Post Check = 0, Pre-Check = 0'); Header ('Last-modified:' GMDAT ('D, Dm YH: I: S', $ this-> Path. Beshenem ($ _ GET ['file'])). 'GMT'); Header ('content-type: application / force-download'); Header ('content-dispute: inline; filename =' '. Bassname ($ _GET [' file ']).' '' '); Header ('content-transfer-encoding: binary'); Header ('content-length:'. Filesypes ($ - path-busname ($ _GET ['file'])); Header ('connection: off'); Readfile ($ this-> Path.basename ($ _GET ['file'])); Go out(); }}}  

Edit: For example, I download a picture and try to view it in iPhotos or Windows Picture Viewer and say it is unsupported when I format it I see it on the server, it looks okay, but after downloading it is corrupt.

Thanks Gumbo, try it and it's output:

Warning : gmdate () expects that the parameter is 2 long, C: \ Program Files \ Wamp Server \ www

/ P>

// filetime added (); Header ('Last-Modified:'. GMDAT ('D, Dm YH: I: S', Filemate ($ - this- & gt; path.busName ($ _GET ['file']). 'GMT ');

Comments