hello it is a very nice component
i have 2 problem
1) how can I save an image in BLOB format on mysql database from Basic file field when an user select it?
2) after the user select the image can i display it?
thx
massimo
Hi massimo,
This came up once before a few years ago - at that time I couldn't get the image to restore from a blob so gave up. It should be possible using PHP + MySQL in a Custom Code action after the Upload Files action.
Why do you need to save it in the database rather than as an image file in a folder?
Bob
Hi Greyhead
I am creating a portal for creating labels that interfaces with the bartender software. this software can load a blob image from mysql
where i insert php code after Upload Files action?
in Edit element settings -> Custom function or
in Setup-> before DBSave?
thanks
Hi greghph,
I would probably do this in two steps. In the On Submit action use:
a. An Upload Files action to get the image info.
b. A DB Save action to save the form data (and the file info if you want to keep a copy on disc).
c. A Custom Code action to get the image data and save that as a blob - you can update the same record using the id that CF will have added to the form data.
d. If necessary, in the same Custom Code action, delete the copy of the file from the server.
Bob
Hi bob
i try but i can't retrieve the image vaues in the custom code
see the screen stamp
Hi greghph,
You'd need to add the image info to the $form->data array for that to work I think; CF has the file path in the $form->files array.
Bob
Hi greghph,
The file info is available in $form->files e.g. $form->files['percorso']['size']
The cf_id is available as $form->data['cf_id'] but only after the DB Save action.
Bob
Hi Bob
thanks very much
but why i can't update the db after DBsave in custom code?
i write this...example for update field size
<?php
//recupero dati che mi servono
$size=$form->files['percorso']['size'];
//$path=$form->files['percorso']['path'];
$ID=$form->data['cf_id'];
// NELLA VARIABILE $data IL CONTENUTO DEL FILE
//$data = addslashes(fread(fopen($form->files['percorso']['original_name'], 'rb'), $form->files['percorso']['size']));
//Update Tabella
$db = JFactory::getDBO();
$query="UPDATE `j35_immagini` SET `size`=" . $size . " WHERE `cf_id`=" . $ID;
$db->setQuery($query);
?>
hi this is the issue
$db = JFactory::getDBO();
$db =& JFactory::getDBO();
Hi greghph,
What exactly is the problem?
Bob