curl_close($ch);
    #$contents = file_get_contents('../vcard.vcf');
    // and save it to a temporary location (so that it gets a nice filename)
    $dir = '/tmp/' . md5(time());
    mkdir($dir);
    $tempFile = $dir . '/NeilCrosby.vcf';
    file_put_contents($tempFile, $contents);
    // send the email
    require 'geekMail-1.0.php';
    $geekMail = new geekMail();
    $geekMail->setMailType('text');
    $geekMail->from('*****@*****.**', 'Neil Crosby');
    $geekMail->to($email);
    $geekMail->subject("Neil Crosby's vCard");
    $geekMail->message("Thanks for downloading my vCard.\n\nIf you're using an iPhone, scroll down to the bottom of the attached card to add it to your address book.\n\nDon't forget you can always get an up to date copy from http://neilcrosby.com/vcard");
    $geekMail->attach($tempFile);
    if ($geekMail->send()) {
        unlink($tempFile);
        header("Location: http://neilcrosby.com/vcard/via-email/sent/");
    } else {
        $errors = $geekMail->getDebugger();
        print_r($errors);
    }
    unlink($tempFile);
    exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
    <head>
    $res = mysql_query($query);
    while ($row = mysql_fetch_row($res)) {
        //mysql_fetch_assoc
        if ($row[6]) {
            // post 18/11/11 proper file path and name
            if ($row[5]) {
                $filename = $row[5] . $row[6];
                $filename = resolveFilePath($filename);
            } else {
                $filename = HEURIST_FILESTORE_DIR . $row[6];
            }
        } else {
            $filename = HEURIST_FILESTORE_DIR . $row[0];
            // pre 18/11/11 - bare numbers as names, just use file ID
        }
        $geekMail->attach($filename);
        array_push($files_arr, array($row[1], $row[3]));
        //name, ext   $row);
    }
    $_POST[$key_file] = $files_arr;
    //@todo delete from database and remove files (after send an email)
}
//files already on server side in database - we don't need to analyse
/*
if ($_FILES) {
foreach ($_FILES as $eltName => $upload) {
// check that $elt_name is a sane element name
if (! preg_match('/^type:\\d+$/', $eltName)  ||  ! $_FILES[$eltName]  ||  count($_FILES[$eltName]) == 0) continue;

if (! $upload["size"]) continue;
foreach ($upload["size"] as $eltID => $size) {