User's Manual
Using Oracle LOBs to Store and Load Employee Images
Beta Draft Loading Images 7-3
<th>Commission<br>(%)</th>
<th>Remuneration</th>
<th>Photograph</th>
The data for the Photograph column is populated with an <img> tag whose src
attribute is defined as a URL reference to a new anyco_im.php file, which will
display the image for each employee.
8. Edit anyco_ui.inc. Add code in ui_print_employees() to generate an
<img> tag referencing the anyco_im.php file with the employee identifier as a
parameter:
echo '<td align="right">'
.htmlentities($emp['REMUNERATION']).'</td>';
echo '<td><img src="anyco_im.php?showempphoto='.$emp['EMPLOYEE_ID']
.'" alt="Employee photo"></td>';
9. Edit anyco_ui.inc. To enable images to be uploaded when a new employee is
created, add an enctype attribute to the <form> tag in
ui_print_insert_employee():
<form method="post" action="$posturl" enctype="multipart/form-data">
At the bottom of the form add an upload field with input type of file:
<tr>
<td>Commission (%)</td>
<td><input type="text" name="commpct" value="0" size="20"></td>
</tr>
<tr>
<td>Photo</td>
<td><input type="file" name="empphoto"></td>
</tr>
10. Create anyco_im.php. This file accepts an employee identifier as a URL
parameter, reads the thumbnail from the Photograph column for that employee,
and returns the thumbnail image to be displayed:
<?php // anyco_im.php
require('anyco_cn.inc');
require('anyco_db.inc');
construct_image();
function construct_image()
{
if (!isset($_GET['showempphoto'])) {
return;
}
$empid = $_GET['showempphoto'];
$conn = db_connect($err);
if (!$conn) {
return;
}
$query =
'SELECT employee_thumbnail
FROM employee_photos