Ad Widget

Collapse

uploading image in postgresql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rcats
    Junior Member
    • Oct 2007
    • 7

    #1

    uploading image in postgresql

    I've found a bug for uploading images to the postgresql database.
    When I upload a image to the database the record will be filled with double \\ and it must be with single \. You can change this in the DB.

    best regard,

    Remco Cats
  • joggl62
    Junior Member
    • Jan 2008
    • 6

    #2
    Postgresyl image-file

    I have also the problem with loading the image-File (png)in postgresql. i get an error for the //.
    Have anyone a solution for this problem? Thanks !

    Comment

    • rcats
      Junior Member
      • Oct 2007
      • 7

      #3
      the solution is as follow:
      get the data from the database after uploading the image.
      copy the data in notepad and replace the following data in the file:
      replace \\ with \ and replace '''' with '.
      Than copy back the data in the database and it will work.

      best regards,

      Remco

      Comment

      • rcats
        Junior Member
        • Oct 2007
        • 7

        #4
        Solution

        The Solution for uploading images with a progress databases is changing the return query of the postgreSQL database in "includes\images.inc.php":
        In function: function add_image($name,$imagetype,$file)
        else if($DB_TYPE == "POSTGRESQL")
        {
        $image = pg_escape_bytea($image);
        return DBexecute("insert into images (imageid,name,imagetype,image)".
        " values ($imageid,".zbx_dbstr($name).",".$imagetype.",'".$ image."')");
        }

        Comment

        • joggl62
          Junior Member
          • Jan 2008
          • 6

          #5
          syntax error

          Thanks for the solution.
          Now i get the following errors.
          Wath can be the solution for this? any idea? :

          invalid command \221J
          invalid command \376s
          invalid command \221J
          invalid command \376s
          invalid command \'
          invalid command \'
          invalid command \036
          invalid command \275
          invalid command \223
          invalid command \'
          invalid command \221J
          invalid command \376s
          invalid command \003
          invalid command \370$
          invalid command \242
          invalid command \306
          invalid command \274
          invalid command \262i
          invalid command \000
          invalid command \'
          ERROR: syntax error at or near "INSERT"
          LINE 2: INSERT INTO images VALUES (2,1,'Hub (small)','\211PNG\015\01...
          Edit/Delete Message

          Comment

          • rcats
            Junior Member
            • Oct 2007
            • 7

            #6
            solution for your problem

            Hi Joggle62,

            Your problem is that you messed up the " with the ' in the image file they are using ' try to use " in your query so that the ' are interperted as a string value and not as a string close.

            best regard,

            Remco

            Comment

            • simonuk1
              Member
              • Mar 2009
              • 66

              #7
              Is this suppose to be fixed in version 1.6.5, as I still get the problem when I upload a png ?

              I can an error messages created as an image saying the paramters arent correct.

              I can post the error message if needed.

              Cheers

              Simon

              Comment

              • simonuk1
                Member
                • Mar 2009
                • 66

                #8
                Error message is

                Last edited by simonuk1; 16-07-2009, 15:12.

                Comment

                • thebrowser
                  Junior Member
                  • Jul 2006
                  • 9

                  #9
                  I posted the solution here:


                  ----
                  I was able to fix the issue, the previous code given by Steve Ruiz is buggy.

                  in function add_image from include/images.inc.php, replace:

                  else if($DB['TYPE'] == "POSTGRESQL"){
                  $image = pg_escape_bytea($image);
                  }

                  by
                  else if($DB['TYPE'] == "POSTGRESQL"){

                  $image = pg_escape_bytea($image);
                  return DBexecute("insert into images (imageid,name,imagetype,image)".
                  " values ($imageid,".zbx_dbstr($name).",".$imagetype.",'".$ image."')");

                  }

                  the point is that postgresql expect the $image part of the request to be between quotes ', while this is not required by mysql.

                  Sincerely,

                  Julien Poummailloux

                  Comment

                  Working...