#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Question Right-Click -> Save-As causing corrupt(?) file


    [editing to clarify]
    I am generating a csv file with PHP with a .txt extension on a CentOS server.

    If I FTP this file down using either ASCII or Binary mode, it works fine. If I right-click and Save As from my browser (happens in IE and Firefox), it blows up my merge document (Word 2007).

    The good file and the bad one are exactly the same size. I've done a byte by byte value comparison and the files are identical. To make the bad file good, all I have to do is open it in GVim and save it. Saving it in Notepad does not make it good.

    I'm baffled as to what is wrong with this file when downloading through the browser that is not wrong when using FTP. It does not appear to be an end-of-lines problem as I have tried a number of combinations.

    Any ideas?
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,297
    Rep Power
    7170
    Do the two files have an identical md5 checksum?
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by E-Oreo
    Do the two files have an identical md5 checksum?
    The md5 checksums are identical in both text and binary mode.
    Inspection with od says the files are identical.
    Diff says the files are identical.
    A C program that does a byte by byte inspection says the files are identical.

    I'm at a loss as to what's going on.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0
    I found the problem. Windows was helping me. They're very helpful.

    It noticed that the file "came from another computer" and silently blocked it to "protect" me. To make the file not blow things up, I had to go to it's properties and click the Unblock button.

    Since the metadata is stored outside the file, the files themselves were identical.

    Thanks for your help!

IMN logo majestic logo threadwatch logo seochat tools logo