Hi,
I think it will be a mess if i try and display binary data to HTML webpage. Now instead of uploading the image to mysql, i am trying to upload it to a folder and i save the path to that uploaded file on the server.
The upload part works fine, plus the query saves the path to the server too. But it has some troubles retreving the image. Seems like i am not saving the path in a right format on the mysql server. I've defined the pathname coloumn as"VARCHAR".
Is that correct??? If not what would be the best way to do it??
Code: Select all
$doc_directory = "/var/www/html/";
$my_file ="images/".$fileName;
1
$copy_path = $doc_directory.$my_file;
if(!copy($tempName, $copy_path))
{
echo "file upload failed";
}
else{ echo"file uploaded at $fileName";}
$query = "insert into product (itemName, itemPrice, subcatid, imagepath, description)".
"values ('$itemName', '$itemPrice', '$subcatid', '$fileName', '$itemdesc')";
That is my upload query.
And here's my retrive query
Code: Select all
$query = "select * from product where subcatid = '$subcatid'";
$result = mysql_query($query) or die('Error, query failed');
//$row = mysql_fetch_array($result);
?>
<table border="0" cellspacing="1" cellpadding="1">
<?
while ($row = mysql_fetch_row($result))
{
extract($row)
echo $row[5];
?>
<tr>
<td width="150" height="120" align="center"><?php echo '<img src="/images/$row[5]" width="150" height="150" >';
Please Help!!
This time i've tried using the PHP tags from the menu, i hope it works...lol
dynamic_desi
feyd | this is the final time I fix your posted code. I'd suggest you study how bbcode tags work..