Hi
I have a form that have a lot of text field, checkbox and a file field. like this:
When i use chronoform and upload a file that's ok!
The problem is, when go to edit: suppose that there is a file. if the field file_0 is empty and i click submit, the link to the file previously uploaded is lost because chronoconnectivity insert a NOFILE value in file_0.
I need that: if there is a previously uploaded file and i don't edit field file_0 the file stay in the server.
If i'll change file_0, then upload another file, then i'll delete the old file and upload the new file.
Sorry for Bad English.
I have a form that have a lot of text field, checkbox and a file field. like this:
<input class="cf_fileinput cf_inputbox" title="" size="20" id="file_0" name="file_0" type="file" />
When i use chronoform and upload a file that's ok!
The problem is, when go to edit: suppose that there is a file. if the field file_0 is empty and i click submit, the link to the file previously uploaded is lost because chronoconnectivity insert a NOFILE value in file_0.
I need that: if there is a previously uploaded file and i don't edit field file_0 the file stay in the server.
If i'll change file_0, then upload another file, then i'll delete the old file and upload the new file.
Sorry for Bad English.
Hi rushseeker,
I think that this may solve that problem.
In the Form OnSubmit Before Email box add this code snippet:
Bob
I think that this may solve that problem.
In the Form OnSubmit Before Email box add this code snippet:
<?php
$file_0 = JRequest::getString('file_0', '', 'post');
if ( !$file_0 ) {
unset($_POST['file_0']);
}
?>
This should make sure that the empty value isn't saved to the database table.Bob
thank you for your answer.
this solution don't work.
this solution don't work.
Worked for me (version 3.2).
Just make sure you didn't copy Bob's typo of the curly bracket instead of the square one after the POST key:
[code]unset($_POST['file_0'});[/code]
Should be
Emanuel.
Just make sure you didn't copy Bob's typo of the curly bracket instead of the square one after the POST key:
[code]unset($_POST['file_0'});[/code]
Should be
unset($_POST['file_0']);
Emanuel.
Hi menchee & rushseeker,
Sorry about the typo, I corrected my earlier post.
Bob
Sorry about the typo, I corrected my earlier post.
Bob
Hi all,
I'm trying to do this as well but the posted code snippet is not helping. My upload field is called 'photo' so I replaced 'file_0' with 'photo' everywhere in the code, but that didn't help either.
Maybe I put it in the wrong place...I didn't see "OnSubmit Before Email" so I put a Custom Code box in between "Upload Files" and "DB Save" in my events.
Any tips? I have the latest versions (as of today) of CF and CC for Joomla 2.5.
I'm trying to do this as well but the posted code snippet is not helping. My upload field is called 'photo' so I replaced 'file_0' with 'photo' everywhere in the code, but that didn't help either.
Maybe I put it in the wrong place...I didn't see "OnSubmit Before Email" so I put a Custom Code box in between "Upload Files" and "DB Save" in my events.
Any tips? I have the latest versions (as of today) of CF and CC for Joomla 2.5.
Hi Megana,
Best way to do this is to load the ex-file name into a hidden field BEFORE the upload file, and disable the "upload file ghost" if you have it enabled (under the file field settings), that should keep the latest uploaded file name.
If you want to do it the same way here then you can use this code instead:
That code should go in a custom code action AFTER the "Upload files" action.
Regards,
Max
Best way to do this is to load the ex-file name into a hidden field BEFORE the upload file, and disable the "upload file ghost" if you have it enabled (under the file field settings), that should keep the latest uploaded file name.
If you want to do it the same way here then you can use this code instead:
<?php
if(empty($form->data['file_field_name'])){
unset($form->data['file_field_name']);
}
?>
That code should go in a custom code action AFTER the "Upload files" action.
Regards,
Max
This topic is locked and no more replies can be posted.