Update file upload
I have a form that has an Upload file control on it, and it allows the user to upload a single file.
This works for saving a record for the first time.
I am building an edit form for the records, that is currently working. It loads all the data from the database and I can then update the values and hit save to have the database updated with the new values.
What I cannot seem to do is update the uploaded file. Essentially I want to have a file upload control on the form that has a title of File Upload (to replace existing file)...so if a new file is selected the database value will be overwritten and the new file will be uploaded to the file server. For some reason I cannot get this to work. When I click submit with a newly selected file, nothing happens (although the rest of the fields on the form save ok. Any thoughts on how to achieve this?
This works for saving a record for the first time.
I am building an edit form for the records, that is currently working. It loads all the data from the database and I can then update the values and hit save to have the database updated with the new values.
What I cannot seem to do is update the uploaded file. Essentially I want to have a file upload control on the form that has a title of File Upload (to replace existing file)...so if a new file is selected the database value will be overwritten and the new file will be uploaded to the file server. For some reason I cannot get this to work. When I click submit with a newly selected file, nothing happens (although the rest of the fields on the form save ok. Any thoughts on how to achieve this?
Hello natloz,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How can I edit uploaded files in a form?
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How can I edit uploaded files in a form?
P.S: I'm just an automated service😉
Hi natloz,
If the File Upload isn't working then it may not be configured correctly. What do you see in the Debugger output?
The FAQ that Prof Calculus found has a solution that will work.
Bob
If the File Upload isn't working then it may not be configured correctly. What do you see in the Debugger output?
The FAQ that Prof Calculus found has a solution that will work.
Bob
[attachment=0]UploadFields.jpg[/attachment]Let me break this down to make sure I am setting things up correctly
1) I have a form called IDEA that saves to an underlying database table along with one field called "fileUpload". The initial save works and the file is uploaded to the folder within the IDEA under \chronoforms\uploads\idea
2) I have developed an edit form called IDEAREVIEW which creates a hyperlink to the previously uploaded file if it exists (this is working) off of a field called "fileUpload" see code that is in custom code event located on DESIGNER screen.
3) I have added a File Upload control to enable the user to re-upload a NEW file if they so choose to overwrite the existing one (FIRST QUESTION: does this field name need to match the underlying database column name or is the field it gets pushed to defined in the "Files Upload" routine within the "Files config" area?)
1) I have a form called IDEA that saves to an underlying database table along with one field called "fileUpload". The initial save works and the file is uploaded to the folder within the IDEA under \chronoforms\uploads\idea
2) I have developed an edit form called IDEAREVIEW which creates a hyperlink to the previously uploaded file if it exists (this is working) off of a field called "fileUpload" see code that is in custom code event located on DESIGNER screen.
<br>
<?php
$filepath = $form->data['idea']['fileUpload'];
if (strlen($filepath) > 0){
echo "<a href='https://myproblem.ca/components/com_chronoforms5/chronoforms/uploads/Idea/$filepath' target='_blank'>Click to View Attachment</a>";
} else {
echo "No Attachment";
}
3) I have added a File Upload control to enable the user to re-upload a NEW file if they so choose to overwrite the existing one (FIRST QUESTION: does this field name need to match the underlying database column name or is the field it gets pushed to defined in the "Files Upload" routine within the "Files config" area?)
Hi natloz,
First answer: the name is set in the File Field element (though you can always use a Custom Code action to copy or move files or variable if necessary).
The Debugger action is your friend here as it will show you what data is present at any stage in the form processing.
Bob
First answer: the name is set in the File Field element (though you can always use a Custom Code action to copy or move files or variable if necessary).
The Debugger action is your friend here as it will show you what data is present at any stage in the form processing.
Bob
Ok, this is with Debugger placed after render HTML. Value has been retrieved from the query ok and is sitting in item[fileUpload]
Array
(
[option] => com_chronoforms5
[chronoform] => IdeaReview
[PID] => 44
[cf_id] => 21
[48924a091bc45838e18e00ce840737be] => 1
[problem] => Array
(
[problemTitle] => Test problem # 2
)
[idea] => Array
(
[cf_id] => 21
[ideaTitle] => Test Idea with Attatchments
[ideaDescription] => <p>This is a tester with an attatchments</p>
[fileUpload] => 20160619082112_TirePile.jpg
)
[user] => Array
(
[email] => blah@blah.com
)
)
Ok, this is with Debugger placed after render HTML. Value has been retrieved from the query ok and is sitting in item[fileUpload]
Array
(
[option] => com_chronoforms5
[chronoform] => IdeaReview
[PID] => 44
[cf_id] => 21
[48924a091bc45838e18e00ce840737be] => 1
[problem] => Array
(
[problemTitle] => Test problem # 2
)
[idea] => Array
(
[cf_id] => 21
[ideaTitle] => Test Idea with Attatchments
[ideaDescription] => <p>This is a tester with an attatchments</p>
[fileUpload] => 20160619082112_TirePile.jpg
)
[user] => Array
(
[email] => blah@blah.com
)
)
Ignoring what is already there in the database, if I place a File Upload control on my form, what would I have to name it for it to overwrite my stored entry and have it upload a new file once the user selects a file? It seems that the event is not firing correctly and that there is no data for my newly selected file. This is place directly after the Submit event.
Array
(
[option] => com_chronoforms5
[chronoform] => IdeaReview
[PID] => 44
[cf_id] => 21
[event] => submit
[idea] => Array
(
[cf_id] => 21
[ideaTitle] => Test Idea with Attatchments
[ideaDescription] => <p>This is a tester with an attatchments</p>
)
[captcha] => gx7ia
[ideaSubmit] => Submit
[48924a091bc45838e18e00ce840737be] => 1
)
This topic is locked and no more replies can be posted.