Buy Now
Sign in

file input in fields form

webcrea , February 14 2019, 08:43
webcrea 581
February 14 2019, 08:43 #383886
hi,
I have a form with several input text, textarea, checkboxes...
All works until i add an input file
Query become an INSERT instead of UPDATE
You can see in debug all the another input doesn't appears in data.person
 [person] => Array
(
[pcs_file] =>
)
And update becomes insert
[save_person] => Array
(
[data] => Array
(
[pcs_file] =>
[created] => 2019-02-14 08:39:45
[author] => 1003587
)

[_success] => Data saved successfully
[log] => Array
(
[0] => INSERT INTO `skf0d_admincrm_prospects_map` (`pcs_file`, `created`, `author`) values ('', '2019-02-14 08:39:45', '1003587');
)
Christophe
http://www.webcrea.fr
admin 27
February 27 2019, 19:15 #384230
Hi Christophe,
Does the table have a primary key ? if yes then what is it ?
You can force the action of the save in the action settings!
Best regards
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
webcrea 581
February 28 2019, 07:34 #384250
Hello Max, Grrr
Yes there is a primary key. The save/update works correctly until i added the input file.
I solved this issue with 2 forms, one for all and one just for the file but ...
Regards
Christophe
http://www.webcrea.fr
healyhatman 6
February 28 2019, 07:54 #384252
If you want it to update, set it to update. If you want it to insert, set it to insert.
If you want it to update an existing record and insert if there's no existing record, then
1) read data
2) In the Found event, put a save data set to update
3) In the Not Found event, put a save data set to insert.
Or try the "Insert - on duplicate key update" option instead.
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
webcrea 581
February 28 2019, 08:03 #384253
 Answer
My problem wasn't only update / insert case but the value of all the other fields. They didn't passed when i add the input file in the form.
It's ok, i solved the problem
Thanks healy
Christophe
http://www.webcrea.fr
amheng5 117
March 02 2019, 20:59 #384352
Hi Christophe

Would you mind sharing how you solved the problem?

My issue is a form is submitted in CF6 with option to upload a file or not. (person does not need to sign in to complete this form). When the user submits uploads a file with the CF6 form, I want to edit in CC6 as needed to an updated file for the form submitted OR I want to upload a file for those forms not submitting a file on intial CF6 form submit.

My dilemma is my setup, I am able to edit any other content field but not my CF6 input field in CC6 edit.

You insight will be appreciated. Thanks
webcrea 581
March 03 2019, 09:55 #384368
Hi amheng5,
I didn't really solved this issue. I make 2 forms : one for all and one only for upload file.
The2 forms are developped with CC6
Christophe
Christophe
http://www.webcrea.fr
healyhatman 6
March 03 2019, 10:02 #384369
What exactly is the problem? Why can't you edit when you're uploading a file amheng5, what's the deal?
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
amheng5 117
March 11 2019, 18:34 #384715
Ok, I've tried to figure out for past few weeks how to set up an CC6 file upload form to edit an exisiting CF6 form that allowed visitors to upload a file as part of the form

I have no problems with my CC6 Edit form to updating any other field except my file upload field.

I created two separte forms as suggested above; one form all regular non file fields and one specific to update file upload.

I'll try to be as clear as possible to explain my current CC6 setup to update an file upload submission under CF6.

My file update form (fields) is exactly as it appears on the CF6 form.

FUNCTIONS tab
Save Data: save_update_file
data provider: {data:model}
Write actin: auto detect (I've tried Update but no luck)
data override on insert: blank
Data overide on Update: file_upload:{data:file_upload}
Update condition: aid:{data:model_aid}

VIEWS Tab
I created a form
Event: save_photo
Form name: photo_update_form
Action URL: Blank
Content: {view:photo_fields}

I created fields
Field: hidden field for my key value (aid)
Field: File -->under name:model[field}
Button: Submit --> name: save_photo
EVENTS Tab
edit_photo -->
{fn:read_single_record}
{fn:check_record_exists}
{view: photo_update_form}

save_photo -->
{fn:save_photo_update}
{fn:check_photo_save}
{redirect:index}


I just can't figure out where I am going wrong. Existing file will not update or a new file will not appear of initial cf6 submission to upload was left blank.

Again, my form for editing all my other fields made in CF6 is updating correctly. But my file upload field is not making any changes, whether there was an initial file or not under the initial CF6 submission.

Hope a clear explanation can be provided for a non-programmer. Thanks
healyhatman 6
March 12 2019, 06:17 #384735
Your save_update_file should absolutely be set to Update.
Put a {debug:} in as the last action in the event to see what data you have available. I suspect your model_aid might be empty. Additionally, your Save Data should be storing the filename returned by the FILE UPLOAD action, NOT the file field, because the filename given to the file on your server might very well be different to the filename of the file from the user's computer.
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
webcrea 581
March 12 2019, 07:51 #384736
>the filename given to the file on your server might very well be different to the filename of the file from the user's computer.
Yes, the uploaded file when another file was upload adds the date in file name...
Christophe
http://www.webcrea.fr
GreyHead 64
March 12 2019, 09:52 #384749
Hi,
Please see this FAQ and this FAQ - they are old but might be helpful. NB the code needs updating for CFv6.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
healyhatman 6
March 12 2019, 09:55 #384750
Nah Bob he just needs to save {var:upload#.path} or .filename can't remember top of my head
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
amheng5 117
March 13 2019, 15:00 #384782
So I placed debug in the "save_photo_upload" event.
Here's the result. Sometimes I want to have some records have the same filler image.Capture.JPGsorry not sure why so many attachmemts were added to this reply.
Attachments
Capture.JPG
Capture.JPG
(50.57 KiB)
81 Downloads/Views
Capture.JPG
Capture.JPG
(50.57 KiB)
80 Downloads/Views
Capture.JPG
Capture.JPG
(50.57 KiB)
108 Downloads/Views
healyhatman 6
March 13 2019, 20:03 #384798
What is that screen? It's certainly not the debug I was after
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
amheng5 117
March 13 2019, 20:06 #384799
healyhatma,I know electronic response does not show sincerity, but I feel so encouraged on your response--not. I'm just frustrated, so excuse my abruptness. I don't know what you are expected. I'm still working it out based on the suggestions by Max.
healyhatman 6
March 13 2019, 21:41 #384800
Put a {debug:} in as the last action in the event to see what data you have available.
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
admin 27
March 14 2019, 19:14 #384848
Passing a value for the primary key of the record to the "Save data" action and setting the action to "Auto" or "Update" will update the record data, if a value is passed for the "file" field in the table then it will be updated, the upload action sets the value of the file field name in the data array to be the name of the "saved file on server", so it should be fine to use this in the "Update data override":
pkey_name:{data:pkey_form_field_name}
table_file_field_name:{data:form_file_field_name}
You may also set the action to "Update" and provide the primary key value in the "Conditions" box!
Best regards
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!