Zubrag.com
September 09, 2010, 11:00:32 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: downloaded file is different size than original  (Read 1993 times)
arffer
Newbie
*
Posts: 1


« on: June 03, 2009, 06:24:44 pm »

Sorry I posted this before in the comments section, my bad. So here it is where it belongs  Smiley

First, thanks for the script!

Second, I've done a number of file uploads, which I then downloaded using your script. The filesize of the download is two bytes larger than the original and the uploaded file on the server. Only the file downloaded with the script is larger. Using a hex editor, I can see two tabs have been appended to the end of the file (0x09 0x09). Tested files were a zip, an rtf, and a pdf.

Any thoughts? Thanks!

Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #1 on: June 04, 2009, 03:01:34 am »

How very odd, I will look into this as I use this script daily, thanks for pointing out
Logged

mtg
Newbie
*
Posts: 15


« Reply #2 on: June 08, 2009, 11:48:44 am »

This does not happen to me and the file residing on the server and the file downloaded are exactly the same when comparing them in a hex editor. My script is slightly modified though. Are there tabs in the script somewhere on download before it closes the file?
Logged
mtg
Newbie
*
Posts: 15


« Reply #3 on: July 08, 2009, 12:19:35 pm »

I'm actually experiencing a similar problem to this now, but it's only for certain file types. Right now it's happening with PowerPoint files (PPT). There is a carriage return line feed being added to the very beginning of the file somehow which is corrupting it and making it unopenable. I thought maybe there was a carriage return in the script somewhere, so I copied and pasted the code into WordPad and then back into my text editor, but no success. Perhaps it's a bug in PHP.
Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #4 on: July 12, 2009, 02:42:58 am »

Hmm, the way the PHP code works is it grabs each line from the file, and sends it to the user:
Code:
while(!feof($file)) { //While it is not the end of the file
    print(fread($file, 1024*8)); //Print it to the user
    flush();
    if (connection_status()!=0) {
      @fclose($file);
      die();
    }
  }
So anything added to the end, or the beginning, is due to some editing of other code, make sure there is no spaces in the PHP document at the start, make sure it's "<?php.." not " <?php..".
As you have noticed, even a small space can make a big difference to the code.
Logged

mtg
Newbie
*
Posts: 15


« Reply #5 on: July 13, 2009, 07:46:21 am »

I found the problem finally. I had this script working on another site without this problem. Problem was only occurring on a new site and I knew it had to be something with a space somewhere. Wasn't a space, but another programmer here edited the file at some point and had an additional opening <?php tag in the code that was just sitting there for no reason. Probably would have worked if it was closed further in the code, but it wasn't needed at all. It was actually affecting all files, but some could still be opened by their respective programs.
Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #6 on: July 13, 2009, 03:44:01 pm »

Thanks for the update mtg, glad it is working now. Yea Microsoft and other files that contain a lot of data do need to be exactly right, but most can cope with lines of white space (as far as I know).

I'm just glad its working Wink
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC