Forums

file uploads with dynamic names

joomla_tatsu 31 Oct, 2010
I was wondering if it was possible to set up the file uploads to take names from certain fields in the form?

Im setting up a nomination form, where applicants upload information about their activities so all the uploads need to have a reference to their name.

Im new to php so Im not sure how this is achieved.

Thanks.
joomla_tatsu 31 Oct, 2010
Bob,

Thanks so much, I inserted the below code into the filename part of the upload tab in the mother form, as per the section in the cookbook:

$filename = date('YmdHis').'_JRequest::getWord('nominee_name', '', 'post').'_JRequest::getWord('nominee_surname', '', 'post').'_'.$chronofile['name'];


Is this correct? substituting the 'input_name' for the ID for the form input you want the information to be extracted from?

Im unable to test whether this is working as I can not figure out why my form is failing to save to the table created with on the mother form.

I have a 7 step form + mother form, which wont submit to the table set on the mother form.

Mother form html to recall cf_id:

    <input type='hidden' name='step_name' id='step_name' value='<?php echo $MyForm->formrow->name; ?>' />
    <?php
    $cf_id =& JRequest::getString('cf_id', '', 'post');
    if ( !$cf_id ) {
      $last_step_name =& JRequest::getString('step_name', '', 'post');
      if ( $last_step_name ) {
        $formData =& CFChronoForm::getInstance($last_step_name);
        $data =& $formData->tablerow['jos_assessments'];
        $cf_id = $data->cf_id;
      }
    }
    echo "<input type='hidden' name='cf_id' id='cf_id' value='".$cf_id."' />";
    }
    ?>

I had this working before and it was all publishing to the one row in the table but something happened when i was playing with the confirmation plugin, and emails, which corrupted the table for this form and i had to recreate it. now its not working and i cant remember what i did. i

table set on mother form only.
mother form only form set to send form data to table
emails on mother form only - wont send as no results saved.
no confirmation form plugin
thank you message displays as set on mother form but no dynamic names displayed.
redirect url sends up blank white page.

any help would be great. Have a feeling its something ridiculously simple. Thanks

GreyHead 03 Nov, 2010
Hi Joomla_tatsu,

You have a stray or missing quote ' left in there. Please try this version:
$filename = date('YmdHis').'_JRequest::getWord('nominee_name', '', 'post').'_'.JRequest::getWord('nominee_surname', '', 'post').'_'.$chronofile['name'];

Bob
This topic is locked and no more replies can be posted.