我在DB的MySQL像BLOB類型的問題上傳圖片我要去包括腳本db和形式和PHP上傳文件的代碼上傳照片到MySQL如何通過PHP5
SQL腳本
CREATE TABLE IF NOT EXISTS `images` ( `id` int(11) NOT NULL AUTO_INCREMENT, `data` longblob NOT NULL, `descripcion` varchar(240) COLLATE utf8mb4_spanish2_ci NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish2_ci AUTO_INCREMENT=1 ;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */; /*!40101 SET [email protected]_CHARACTER_SET_RESULTS */; /*!40101 SET [email protected]_COLLATION_CONNECTION */;
的index.html(上傳形式)
<html>
<head>
</head>
<body>
<form method="post" action="insertar.php" enctype="multipart/form-data">
<label>elige imagen:</label>
<br/>
<input type="file" name="imagen"/>
<br/>
<label>descripcion:</label>
<br/>
<textarea cols="20" rows="10" name="texto"></textarea>
<br/>
<input type="submit" value="enviar"/>
</form>
</body>
</html>
insertar.php(上傳代碼)
<?php
include "conexion.php";
$archivo=$_FILES['imagen']['name'];
$texto=$_POST['texto'];
$id=rand(1,200);
$insertar=mysql_query("INSERT INTO image VALUES('".$id."','".$archivo."','".$texto."')");
if($insertar){
echo "<a href='verImagenes.php'> ver mis imagenes</a>";
}else{
echo "fallo la insercion";
}
?>
,這是錯誤消息:
通知:Array對字符串的轉換在C:\ XAMPP \ htdocs中\上線ejemplo \ insertar.php 9
'$ _FILES ['imagen']'是一個包含上傳文件信息的值數組。請參閱:http://stackoverflow.com/a/5445223/1745573 – Jon 2013-04-25 01:42:41