SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Sep 2001
    Location
    netherlands
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Data corrupt after up- and download

    Hello,

    I've written an upload and download site where i can store files on the website (insite MySQL database).

    If I upload a file, and then download it, i get (for me) corrupt documents back. The document name is OK, the size is OK, but when i try to open it i get an error that the data is corrupt (word documents, pdf files).

    I used the addslashes/stripslashes method and also the magic_quotes_gpc en magic_quotes_runtime in php.ini. Every combination of these!

    My platform is Linux RH62, MySQL-3.23.42-1.i386, apache_1.3.20, and php-4.0.6.

    Hope you can help


    Twan

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Somewhere along the way (probably when the file is uploaded onto the server) its MIME type is getting confused. I really don't know what I am talking about here - but that sounds like the problem - I don't know the solution.

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, if you post your code we may be able to help more.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  4. #4
    SitePoint Addict jough's Avatar
    Join Date
    Sep 2001
    Location
    You have moved into a dark place. It is pitch blac
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure that you're using a binary-safe field type. That sounds right? I'm not up on the intricacies of storing binary info inside mySQL. It it necessary to store the actual files in the database?

    -- Jough
    My Dynamic Site in Action:
    Poetry X Poetry Archive

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yea, i'd STRONGLY advise against storing the image itself in the database.
    i'd just store it's location on the web server in the database.
    here's the script i wrote to upload a file and store it in the db.
    the pic's name will be the name submitted, with the unix timestamp at the end to make sure that each filename is unique.

    the form
    http://www.rfworld.net/misc/form.phps
    the error script:
    http://www.rfworld.net/misc/error.phps
    and the uploading script
    http://www.rfworld.net/misc/upload.phps
    Last edited by Defender1; Sep 14, 2001 at 03:04.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    SitePoint Enthusiast kcabobert's Avatar
    Join Date
    Aug 2001
    Location
    Topeka, KS
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And to give another possible reason for the corruption when you add or strip slashes it could add and remove them in the wrong part of the file thus perminantly trashing it. I think that the location idea is a god one. Good luck
    Microsoft's Motto: Resistance is futile, you will be assimilated.

    My dog's name is Jade; she is a Miniature pinscher.
    Click here to see some of her pictures

  7. #7
    SitePoint Member
    Join Date
    Sep 2001
    Location
    netherlands
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanx guys

    I've solved it, but i don't know exactly why it's happended.

    I've removed from: mysql_query($kwery, $db) the $db and also removed the stripslashes() and it worked.

    I havn't had time to dive into this problem because the next problem was there, i couldn't upload files larger than 1M.
    The solution to this was adjusting php.ini and configuring mysql with parameters.

    OF COURSE WILL WINDOWS CRASH, IT MICRO$OFT!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •