Forums

Upload File (Filename) when Editing Form

hellykun 04 Apr, 2014
Hello Everyone,
I have a form which is used to Edit my entried in Table created previously from users with chronoforms. (Chronoforms V4 User)

The table has an uploaded filename also.

The problem is that if the user (when editing his data) does not upload a file then the filename entry is replaced with blank.
I tried to use some custom code to get it done but with no luck

Here is my code:
<?php
$uploadedfile = $row->data[‘uploadedfile’]; // (I have created a hidden box that gets the filename from the Database Loader Action)
$uploadedfile2 = $row->data[‘uploadedfile2’]; // (I have placed this after the upload files action
If ($uploadedfile2 != NULL){
$row->data[‘uploadedfile’] = $uploadedfile2;
}
?>
hellykun 04 Apr, 2014
Thanks a lot for your reply.

I have tried the above but it did not work.
The filename gets replaced with blank.

my file is named uploadedfile

the code I used

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


Am i missing something here?
GreyHead 04 Apr, 2014
Hi hellykun,

Please try adding Debugger actions so that you can see exactly what is happening. It may be that the sequence of actions isn't right.

Bob
hellykun 04 Apr, 2014
As far as I can understand from the debugger.
The custom code is not executed at all.
Max_admin 04 Apr, 2014
Answer
The correct sequence should be this:

* Upload files action
* Custom code action with the code above
* DB save action

The debugger may be inserted after the custom code to verify that the uploadedfile field does not exist in the data array when no file is uploaded.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
hellykun 08 Apr, 2014
I had the exact sequence and the uploadfile field continues to exist but it is empty. I will try to debug it when I can and I will post my solution.

Thanks a lot.
This topic is locked and no more replies can be posted.