foxclone Posted March 3, 2022 Share Posted March 3, 2022 When I run the following code on my local apache server, the md5sums of the downloaded files are correct. When I run the code on my web host, I get different md5sums. I've scrubbed the code to eliminate blank spaces before the readfile statement. I'm not getting any errors with error_reporting(E_ALL), display_errors=On, and output_buffering = off in my local php.ini as well as on my web host. Here's the code I'm currently using: <?php function mydloader($l_filename=NULL){ if( isset( $l_filename ) ) { $filename = preg_replace("/\s+/u", " ", $l_filename);//Eliminate any hidden characters $ext = pathinfo($filename, PATHINFO_EXTENSION);{ if ($ext = '.deb') header('Content-Type: application/x-debian-package'); elseif ($ext = '.iso') header('Content-Type: application/x-cd-image'); elseif ($ext = '.gz') header('Content-Type: application/zip'); else header('Content-Type: octet-stream');} header("Content-Disposition: attachment; filename={$filename}"); header('Pragma: no-cache'); header('Expires: 0'); readfile($filename); } else { echo "isset failed"; } } mydloader($_GET["f"]); I've removed all other code from this script in order to eliminate any other issues. Does anyone have an idea what's going on? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 Your if statements are wrong And why are you using this version of the same code that we cleaned up for you earlier? Quote Link to comment Share on other sites More sharing options...
foxclone Posted March 3, 2022 Author Share Posted March 3, 2022 @ginerjm - As I said, that code is working correctly now and does the downloads. The problem now is that the md5sums on the downloaded files is incorrect coming from the server. I removed all the sql code to ensure that it wasn't causing the problem. What's wrong with the if statements? The structure is right from https://www.php.net . Quote Link to comment Share on other sites More sharing options...
Solution ginerjm Posted March 3, 2022 Solution Share Posted March 3, 2022 Well if it is EXACTLY as copied then I don't know what it is doing. If you are trying to ask "is $ext equal to .deb" then you are not doing that. Try 2 equal signs... As for your concern about the md5sums - since there is no code present showing us what is or is not happening, we can't help you. 1 Quote Link to comment Share on other sites More sharing options...
foxclone Posted March 3, 2022 Author Share Posted March 3, 2022 @ginerjm - The problem was with = instead of ==. Thanks a lot! Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 HTH Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.