I can't give you an example, but I can give you a theory.
Don't.
Leave the image on the server and store a link to it in the database. Use a sensible naming system for your files, or if other users are uploading the files just make sure they put the correct name in. Then when you run your SQL query in the web page you can just echo the image name eg:
$query = "SELECT * FROM imagelist WHERE id = '$id'";
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)){
echo '<img src="www.myserver.com/uploads/'.$row['myimagename'].'">';
.
If you keep all your images in one folder, you can then let the db do the hard work of finding them.