don't ever put images IN your database,IT IS SLOW AND UNRELIABLE, the following will store information about the file you are placing in the folder you specify, this is for a doc uploader, but just replace the a href with an img tag and the info from the mysql data and it will pull it back correctly
<?
$conn = mysql_connect("localhost", "mysqluser", "mysqlpass") or die ("Could not connect to database!");
$db = mysql_select_db("databasename") or die ("Could not select database");
$queryview = "select * from tablename";
$resultview = mysql_query($queryview) or die ("Could not upload file");
while ($rowview = mysql_fetch_array($resultview))
{
?>
<a href="<? echo $row['fieldname1']; ?>" target="_blank"><? echo $row 'fieldname1']; ?>"></a><br><br>
}
<?
if (isset($upload))
{
$conn = mysql_connect("localhost", "mysqluser", "mysqlpass") or die ("Could not connect to database!");
$db = mysql_select_db("databasename") or die ("Could not select database");
if ($doc_type == "application/pdf") // this will be different depending on file type ie a jpg would be "image/pjpeg" it checks more than just the extension so if someone made a vbscript file and changed the extension to .jpg, it wouldn't let you upload
{
copy($doc, "file path" . $doc_name); // make sure you have write permissions to directory
echo "<br>File uploaded successfully";
$query = "insert into table name (fieldname1) values ('$doc_name');";
$result = mysql_query($query) or die ("Could not upload file");
}
else
{
echo "<br>Files must have certain extension";
}
}
else
{
?>
<br>
<FORM ACTION="samename.php" METHOD="POST" ENCTYPE="multipart/form-data">
<input name="doc" type="file">
<input type="submit" value="Upload File" name="upload">
</form>
<?
}
?>