download - file downloader with php to webpage -
I develop a webpage and I want to create a download section. I have a PHP code to download the file, but I have tried it many times, but it does not work, I see the error message continuously, but the picture. The JPG file is in the same directory as the downloaded .php and index.php. I do not know what the problem is.
Content of Download.php:
& lt ;? Php if (isset ($ _GET ['file']) & amp; amp; and bassname ($ _GET ['file']) == $ _GET ['file']) {$ filename = $ _GET ['file' ]; } And {$ filename = NULL; } $ Err = '& lt; P style = "color: # 990000" & gt; Sorry, the file you are requesting is unavailable. & Lt; / P & gt; '; If (! $ Filename) {echo $ err; } And {$ path = 'Downloads /'. $ Filename; If (file_exists ($ path) & amp; is_readable ($ path)) {$ size = filesize ($ path); Header ('content-type: application / octet-stream'); Header ('content-length:'. $ Size); Header ('content-dispute: attachment; filename ='. $ Filename); Header ('content-transfer-encoding: binary'); $ File = @ fopen ($ path, 'rb'); If ($ file) {fpassthru ($ file); Go out; } Else {echo $ err; }} Else {echo $ err; }}? & Gt;
Contents of index.php:
I think the letter '
and
Try changing it with the normal single quote ( '
) you're skipping it, and be careful when copying the code to someone's blog;)
Comments
Post a Comment