Varbinary chronoform

kinesistech 18 Oct, 2013
Hi,
I have to save an image with chronoform in a database by using the varbinary data type.
Do you Know if it is possible to do it with chronoform?
Thanks a lot
GreyHead 20 Oct, 2013
Hi kinesistech,

Technically it should be possible but we tried a year or two ago to save images as blobs and could never get them back from the DB table to display them. I usually prefer to just save a path and/or URL.

Bob
kinesistech 22 Oct, 2013
hi, we have to save the images in varbinary, as for the display of the images we will try to get it by ourselves. what is the method to save the images in varbinary? could you explain it?
thank you very much.
Regards,
kinesistech
GreyHead 22 Oct, 2013
Hi kinesistech,

Use a Custom Code action to hand-code the query, I found an example here (note a correction in a later post in the thread).

Bob
kinesistech 24 Oct, 2013
Hi,
thanks for your answer. This code doesn't insert anything in the database. It seems that both of the queries don't work.
We think that the problem consists in the lines written in red, but we can't understand why, given that we tested them on the database and they work.

Thank you very much.
Best regards,

Kinesistech

<?php

$picture = fopen('components/com_chronoforms/uploads/topic_saved', 'rb');

$data = fread($picture, filesize('components/com_chronoforms/uploads/topic_saved'));

$sqlpic = mysql_excape_string($data);

$cfid=$form-> data ['chronoform_data']['cf_uid']

//It's good to find the mime type for later
//if the mime_magic extension is enabled

$mime = mime_content_type('components/com_chronoforms/uploads/topic_saved'))

mysql_query ("UPDATE `topic` SET `logo` = ( '".$sqlpic."' ) WHERE `cf_id` =".$cfid."") or die (mysql_error ());
//
mysql_query ("UPDATE `topic` SET `logo` = ( '$sqlpic' ) WHERE `cf_id` ="$cfid"));

?>

GreyHead 25 Oct, 2013
Hi Kinesistech,

I can see a few typos in your PHP; I suggest that you debug it line by line to make sure that it is correct.
$sqlpic = mysql_excape_string($data);

$cfid=$form-> data ['chronoform_data']['cf_uid']

That should be escape not excape; $form->data with no space not $form-> data; and there's a ; missing at the end of the second line.

Bob
This topic is locked and no more replies can be posted.