Jump to content

Completely Perplexed....


drbigfresh

Recommended Posts

???

So for two days I've been trying to figure this out, with no luck. I have your typical PHP/MYSQL script that uploads files into a database and then let's you download them. It all works fine. So I go to upload to my host (hostgator) and it all seems to work, but any file I download looks like it is a BAD xerox of the original...Where you can make out some text in the background but it's kind of washed out in color.... I've attached a sample.

 

Has anyone ever seen anything like this before? Ive tried everything, and have no issues with using it on my dev server.

 

I've even checked the size of the files stored in the database between my local server and the hostgator one, and the files are the same size in the database. And what's even weirder, is that the file is also being save locally on the server, and it's totally fine and readable....

 

[attachment deleted by admin]

Link to comment
Share on other sites

few issues possible.

1) Your max_upload is less than your files, thus it is getting partial files and the trailing end is being cut off

2) Your mysql db isn't large enough thus it can not have large enough Blob's for the data

3) The header generation is corrupt

4) The output is so slow it timesout and shows what it has.

Link to comment
Share on other sites

Just checked, definitely not 1 or 2. Tons of space. The header generation could be corrupt, but it is working fine on my local server, and it is actually sending me a valid file to download, etc... so it makes me think it isn't a header issue.

 

It could be an output problem, although I cant' really figure out why it would be the issue, they are small files that seem to download almost instantly....

 

FYI, this is the header info I am sending out:

header("Content-type: $type");

header("Content-Disposition: attachment; filename=\"$name\"");

header("Content-length: $size");

//header("Content-Description: PHP Generated Data");

header("Content-Transfer-Encoding: binary");

header("Cache-Control: private"); // Workarounds for IE weirdness

header("Pragma: public");

echo $content;

exit;

 

and I've tried just about every variation or tweak in there I could....

Link to comment
Share on other sites

Why not just store the files in the filesystem and store the path in the database? Then you don't have to worry about data corruption when it tries to insert it into the database.

 

I have tried to store files in the db with no luck. Store em in the file system and let the db keep track of what's there and all is right with the world.

 

that's my 1.5 cents

 

 

Nate

Link to comment
Share on other sites

I don't disagree with you, unfortunately the client feels otherwise.....

 

 

I think I finally solved it.

 

I was running this function on the content of the upload:

function SQLSafeData($data) {

 

// Reverse magic_quotes_gpc/magic_quotes_sybase effects on those vars if ON.

 

        if(get_magic_quotes_gpc()) {

            $data = stripslashes($data);

         

        } //else {

          // $data        = $data;

      // }

       

return mysql_real_escape_string($data);

 

} //End Function

 

 

and somehow removing that and simply running addslashes() on the content seems to have fixed it.

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.