Using data from CiviCRM to change filename
I am assuming that you are a drupal coder (because the upload starts in Drupal). Information from CiviCRM can be used in Drupal by using the CiviCRM. This is documented in the Developer Guide.

An example for finding the first and last name of the current user in drupal is

$uid = $GLOBALS['user']-&gt;uid;   // get id current user

civicrm_initialize(); // needed for classloading

/* find the CiviCRM contact id using the drupal user
$contact_id = civicrm_api3('UFMatch', 'getvalue', array(
  'return' =&gt; "contact_id",
  'id' =&gt; $uid,
));

/* use contact id to find contact details */
$result = civicrm_api3('Contact', 'getsingle', array(
  'id' =&gt; $contact_id,
));

/* create the file name */
$file_name=$result['first_name'].'_'.$result['last_name'];