echo '</p>';
    echo '<p>';
}
// Find the second sample resource.
$fm_request = $fmDemo->newFindCommand('Resource - Form');
$fm_request->addFindCriterion('Resource_ID', '==2');
$fm_result = @$fm_request->execute();
// If the resource was not found...
if (FileMaker::isError($fm_result)) {
    echo '<p>Unable to locate the sample resource.</p>';
} else {
    // Get the record object.
    $resources = $fm_result->getRecords();
    $resource = $resources[0];
    // Call fmGetContainerURL to prepare the resource and generate a URL to access it with.
    $resource_url = fmGetContainerURL($fmDemo, $resource, 'Resource', FALSE, NULL, 60 * 60, NULL);
    echo '<p>Here is a link to another document stored in the database. This one is a PDF document: ';
    echo '<a href="' . $resource_url . '" target="_sample_pdf">' . $resource_url . '</a>';
    echo '</p>';
}
echo '<p>';
echo 'FMWebFrame supports publishing a wide range of file types, from images (gif, jpeg, jpg, png), to movies (quicktime, mp4), to audio files (mpeg), and more. ';
echo 'And best of all, FMWebFrame fully supports all of the latest container storage options, including both the secure and open external storage options.';
echo '</p>';
echo '<p>';
echo 'There are several options that the "fmGetContainerURL" function provides, including:';
echo '<ul>';
echo '<li>You can choose to add UUIDs to the URLs to ensure that they are unique. This is a handy option in cases where ';
echo 'the names of the files stored in the containers might be duplicated, or in cases where you are concerned that  ';
echo 'someone might try guessing at the names of files in an attempt to access them directly.</li>';
echo '<li>You can indicate that a URL should only be valid for a certain amount of time. ';
    $fm_request->setField('File_Name', $_FILES['uploaded_file']['name']);
    $fm_request->setField('File_Type', $_FILES['uploaded_file']['type']);
    $fm_request->setField('File_Size', $_FILES['uploaded_file']['size']);
    $fm_request->setField('Uploader_IP_Address', fmGetRemoteAddress());
    $fm_result = $fm_request->execute();
    if (FileMaker::isError($fm_result)) {
        echo '<h2>An Unexpected Error Has Occurred</h2>';
        echo "Error Code: " . $fm_result->code . "<br>";
        echo "Error Message: " . $fm_result->getMessage() . "<br>";
    } else {
        // Get the record that was just created.
        $resource_records = $fm_result->getRecords();
        $resource_record = $resource_records[0];
        // Upload the file into the new record's container field.
        $resource_record_updated = fmPutContainer($fmDemo, 'Resource - Form', 'Resource', $resource_record, $_FILES['uploaded_file']);
        // fmDump ( $resource_record_updated, TRUE, 'resource_record_updated') ;
        // Get an FMWebFrame URL for the uploaded file.
        $uploaded_file_url = fmGetContainerURL($fmDemo, $resource_record_updated, 'Resource', TRUE, NULL, 60 * 5, NULL);
        echo '<p style="font-weight: bold;">The file was uploaded successfully.</p>';
        echo '<p>To view the file, click here:<br />';
        echo '<a href="' . $uploaded_file_url . '" target="_uploaded">';
        echo $uploaded_file_url . '</a>';
        echo '</p>';
    }
}
// Grab the contents of the output buffer.
$ui_body_content = ob_get_contents();
// End output buffering, and erase the contents.
ob_end_clean();
// Display the page, using the template.
require_once dirname(__FILE__) . '/ui-template.php';