0
我只是用PHP和鍛鍊的一部分,開始我想設計的小網站,讓你上傳的圖像,然後顯示所有上傳的圖片顯示一個MySQL表的BLOB圖像
我得到的圖片上傳成功地工作和圖像存儲在數據庫中,但我不能找到這樣顯示圖像和其他數據
$i=0;
while ($row = mysql_fetch_array($result))
{
echo '<td>'.mysql_result($result,$i,0).'</td>';
echo '<td>'.mysql_result($result,$i,1).'</td>';
echo '<td>'.mysql_result($result,$i,2).'</td>';
echo '<td>'.mysql_result($result,$i,3).'</td>';
echo '<td>'.base64_encode($result,$i,4).'</td>';
echo '<tr>';
$i++;
如何修改代碼一起顯示在表格圖像的方式?
這是用來代碼上傳圖像
if (isset($_FILES['photo']))
{
@list(, , $imtype,) = getimagesize($_FILES['photo']['tmp_name']);
// Get image type.
// We use @ to omit errors
if ($imtype == 3) // cheking image type
$ext="png"; // to use it later in HTTP headers
elseif ($imtype == 2)
$ext="jpeg";
elseif ($imtype == 1)
$ext="gif";
else
$msg = 'Error: unknown file format';
if (!isset($msg)) // If there was no error
{
$data = file_get_contents($_FILES['photo']['tmp_name']);
$data = mysql_real_escape_string($data);
// Preparing data to be used in MySQL query
mysql_query("INSERT INTO {$table}
SET ext='$ext', title='$title',
data='$data'");
這是我測試enter link description here
我一直在尋找在堆棧溢出的例子,但我找不到任何具有循環在它將數據輸出到表中。
仍然不起作用 – corkalom 2013-03-07 16:32:43
什麼是不工作? – Babblo 2013-03-07 19:39:43