MySQL BLOB data corrupted on retrieval

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpmagesh
    New Member
    • Nov 2008
    • 119

    MySQL BLOB data corrupted on retrieval

    Hi

    I have tried this sample code in my database for file update, but some error occurred.

    everything is going fine. uploaded the file successfully but, when i download the file which i uploaded in Database, the file is corrupted or flouted.

    If the uploaded file is image, then the image is not displaying when it is downloaded,

    So totally there is some minor problem with this code, can any one test and help me please. i just tried this in my local server, i got this output.

    Regards
    magesh N

    Moderator note: This has been moved from the Uploading files into a MySQL database using PHP article. -- Atli
    Last edited by Atli; Dec 30 '08, 01:19 PM. Reason: Moved into it's own thread.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi magesh.

    I just tested the code again on my test server (PHP5, MySQL5, Apache2.2).
    Still works fine.

    How is your server set up? Which versions of PHP and MySQL do you use?
    Note that none of my examples specify a character set, so if your database uses something other than the default ISO character set, that *might* be causing problems.

    Also make sure that you replace all database values and that nothing is being printed in the get_file script other than the file itself.

    Comment

    • phpmagesh
      New Member
      • Nov 2008
      • 119

      #3
      Originally posted by Atli
      Hi magesh.

      I just tested the code again on my test server (PHP5, MySQL5, Apache2.2).
      Still works fine.

      How is your server set up? Which versions of PHP and MySQL do you use?
      Note that none of my examples specify a character set, so if your database uses something other than the default ISO character set, that *might* be causing problems.

      Also make sure that you replace all database values and that nothing is being printed in the get_file script other than the file itself.
      Hi,

      Actually i m using Wamp server in my system, php5, Mysql5.0.51 and apache2.2.8.. for me too everything is working fine but the uploaded file is corrupted. i cant able to see what is inside after downloading that file again..

      can you tell me what will be the problem in this,

      Regards
      magesh

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Originally posted by phpmagesh
        can you tell me what will be the problem in this,
        Not really without any more information.
        This code should be working fine on a standard installation of the software you mentioned.

        We would need to know how your server is different from the standard installation.
        Do you use a language specific character set? Like Chinese or Japanese?
        Does your browser default to a character set other than ISO? (Which browse do you use?)

        Try issuing the following command on your MySQL database:
        [code=mysql]SHOW CREATE TABLE FileStorage\G[/code]
        Post the entire CREATE TABLE command that gives you here. (within [code] tags please).
        There I would be most interested in the CHARSET clause at the end. It should be "latin1". If it is not, that might be a problem.

        The corrupted file, how exactly is it corrupted? How does the corruption present itself?
        Can you download it, but it's empty? If not, is there a difference in sizes compared to what MySQL says it should be?

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          I have moved this discussion into it's own thread, to avoid cluttering the article thread.

          Moderator

          Comment

          • phpmagesh
            New Member
            • Nov 2008
            • 119

            #6
            Originally posted by Atli
            Not really without any more information.
            This code should be working fine on a standard installation of the software you mentioned.

            We would need to know how your server is different from the standard installation.
            Do you use a language specific character set? Like Chinese or Japanese?
            Does your browser default to a character set other than ISO? (Which browse do you use?)

            Try issuing the following command on your MySQL database:
            [code=mysql]SHOW CREATE TABLE FileStorage\G[/code]
            Post the entire CREATE TABLE command that gives you here. (within [code] tags please).
            There I would be most interested in the CHARSET clause at the end. It should be "latin1". If it is not, that might be a problem.

            The corrupted file, how exactly is it corrupted? How does the corruption present itself?
            Can you download it, but it's empty? If not, is there a difference in sizes compared to what MySQL says it should be?
            Hi,

            I tried the query which you gave to me, it displayed the follwoing error.

            *************** *************** *************** *********
            Error:

            SQL query:

            SHOW CREATE TABLE FileStorage \ G

            MySQL said:
            #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\G' at line 1
            *************** *************** *************** *************** **********

            What will be the problem in this please can you tell me,

            Thanks in advance,

            Regards
            magesh

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Try removing the \G.

              It is used by the MySQL CLI to sort the rows differently.
              Probably won't work if your using some other client, like phpMyAdmin.

              Comment

              Working...