Forums

fileupload and dbsave

hcohl 27 Apr, 2017
dbsave stores the data of the fileupload but not the path to the file.
When I come next time and read the data od the form, I can see the filename but not the path to the file or the file itself (f.e. the foto)
Is it possible to store the path to the file as well?
GreyHead 27 Apr, 2017
Hi hcohl,

Do you need to? The path is presumably always the same so doesn't need to be saved as you can always add it when needed?

ChronoForms adds the path to $form->files['input_name'[[path'] so you could copy that to the $form->data array and save it.

Bob
hcohl 27 Apr, 2017
My problem is, if I put a file into fileupload > save to db > open the form again and read from db > the file is not shown in the field for fileuploads - the field is empty.
GreyHead 28 Apr, 2017
Hi Hcohl,

That is correct but having the path wouldn't help with that. The only meaningful path in an edit form is the one on the users computer and you don't have that. This FAQ may help.

Bob
hcohl 28 Apr, 2017
Thank you for your answer.
I took the following code, but it doesn't work.

<?php
$files_array = array(
'fileupload'
};
foreach ( $files_array as $v ) {
if ( !$form->data[$v] ) {
unset($form->data[$v]);
}
}
?>

"fileupload" is id of my fileupload-field.
What could be the problem?
This topic is locked and no more replies can be posted.