Thanks for the reply. Please bare with me, I am really new to
this. I made a few changes to the script to work with jpegs
and I changed "doc" in the script to "image" is that right?
This is what I did. Also I notice that you only have one field
for the database? Another is I want to have it that the image
appears in a profile automatically when I set the select
statement like this "select * from table where userid= '$userid'"
How do I set up the rest so that it takes the info from the database
and then calls up the image from the file on the server.
Can you please give me the rest of the scrip to create the
database table and the to call up the image?
Thanks so much. I've been having a lot of trouble with this.
<?
$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))
{
?>
<img src="<? 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 ($image_type == "image/pjpeg") // 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($image, "file path" . $image_name); // make sure you have write permissions to directory
echo "<br>File uploaded successfully";
$query = "insert into table name (fieldname1) values ('$image_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="image" type="file">
<input type="submit" value="Upload File" name="upload">
</form>
<?
}
?>