Forums

Image upload and Chronoconnectivity

yosemite 15 Jan, 2015
Hi,

I created a form to add a new item in a table showed using Chronoconnectivity v5. I used Connection[Data] for every field name and it works, except for the image upload. Using this for the "File field" blocks the "Upload file" action. If I change the "File field" name, the action works. But, even though it works, the image name isn't registered in my database. How could I do this ?

I also have a form made for item editing. I suppose I would need some sort of field which contains the name of the file that was already uploaded, if the item has one, to avoid erasing the file name in the database if the person editing the item does not add a new picture ?

I hope that's clear, it's quite difficult to write down my thoughts in a language thats not my mother tongue.

Thank you for your help,
Quentin
GreyHead 16 Jan, 2015
1 Likes
Hi Quentin,

File uploads are tricky to edit. Please see this FAQ which is for CFv4 but should work for CFv5 as well.

Bob
yosemite 19 Jan, 2015
This helped me a bit, thank you.

The issue I still have is that I'm using the "Connection action" to update the database, but if I use the correct format for the upload field's name, which is Barrier[image], the upload doesn't work. And if I don't use this, the database field "image" isn't updated.

Also, with the FAQ you linked, it doesn't find the image when there's one, should I change the code to make it work with Chronoconnectivity or should I make the form connect to the database on load ?

Thank you,
Quentin
GreyHead 19 Jan, 2015
Hi Quentin,

Sorry I don't know enough about CFv5 to be able to answer this without building a test. Max may be able to help though.

Bob
yosemite 20 Jan, 2015
Thank you for your help Bob,

Is there a magic button to call Max for help ?

Quentin
GreyHead 20 Jan, 2015
Hi Quentin,

Use the Contact Us menu above and link to this thread please.

Bob
Max_admin 21 Jan, 2015
Answer
1 Likes
Hi,

The first way to do this is to use Model[field_name] format for your file field, and add "Model" in the "arrays fields" setting under the "files upload" action.

The 2nd way is to use a field name without model, say "file", and then move the file name value under the model using a "custom code" action AFTER the upload action:

<?php
if($form->data("file")){
$form->data["Model"]["field"] = $form->data["file"];
}


Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
yosemite 23 Jan, 2015
Thanks a lot to both of you, this works perfectly !

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