我在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