Jump to content

Wrong md5sums when downloading from web host


foxclone
Go to solution Solved by ginerjm,

Recommended Posts

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.
    

Link to comment
Share on other sites

@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 .

Link to comment
Share on other sites

  • Solution

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.

  • Thanks 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.