我想将图像插入到 mssql 中,为用户提供选择图像并插入数据库的选项。所以我使用了以下代码
<html>
<head>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
mmysql_connect("localhost","sample","welcome");
mysql_select_db("samples");
if (empty($_POST["frm"]))
{
}
else
{
$filename=trim($_REQUEST['slcfile']);
$datastring = file_get_contents($filename);
$data = unpack("H*hex", $datastring);
echo trim($_REQUEST['slcfile']);
mssql_query("insert into imageinserter values ( 0x".$data['hex'].",'.$filename.')");
}
}
?>
</head>
<body>
<form name="frm" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" >
select image :<input type="file" name="slcfile" /> <br>
<input type="submit" name="slcfile" value="addimage"/>
</form>
</body>
</html>
但它在 file_get_contents 处说错误错误,说没有找到这样的文件或资源。请帮助解决问题
提前致谢