Announcement

Collapse
No announcement yet.

upload and store photo voltdb php

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • upload and store photo voltdb php

    Hi,
    I want to upload a photo into my database and store it with my php application.
    So I start with SQL, I added new attribute to my table:
    Code:
     profile VARBINARY(1048576),
    Now in my php code, I added an input file, and once submetted I execute this code to convert my photo to binary array:

    PHP Code:
    $a file_get_contents($_FILES['photo']['tmp_name']);
        
    $photo = array();
        foreach(
    str_split($a) as $c)
        
    $photo[] = sprintf("%08b"ord($c)); 
    After that I use my stored procedure to insert data to my table but it dosn't work, when I print the response I got this error:
    PHP Code:
    stdClass Object ( [status] => -[appstatus] => -128 [statusstring] => VOLTDB ERRORPROCEDURE USERS.insert TYPE ERROR FOR PARAMETER 1org.voltdb.VoltTypeExceptiontryScalarMakeCompatibleUnable to match parameter array:byte to provided java.lang.String [appstatusstring] => [results] => Array ( ) ) 

  • #2
    Are you sending the photo as a byte array? Can you try sending it as a hex-encoded string to the server?
    Ning

    Comment


    • #3
      I tried : $x=base64_encode($a);

      and the result is:
      VOLTDB ERROR: PROCEDURE USERS.insert TYPE ERROR FOR PARAMETER 1: java.lang.NumberFormatException: For input string: "IV"

      in my sql file I mentioned the attribute " profile VARBINARY(1048576)" should I change it to varchar()??

      Comment


      • #4
        Do you mind sharing the stored procedure signature and the PHP code that calls the stored procedure with us? You can send it to my E-mail if you want. nshi AT voltdb.com

        You don't have to change the column type to VARCHAR. The server understands hex-encoded VARBINARY string.
        Ning

        Comment


        • #5
          Note that hex encoding is not the same thing as base64 encoding. maybe bin2hex is the function you want?

          Comment


          • #6
            thank you, I sent you an email :)

            Comment


            • #7
              @pmartel now with bin2hex there's no more error but the field picture is empty???

              Comment

              Working...
              X