[英]Warning: Illegal string offset 'mime'
我正在嘗試將圖像存儲在MySQL中並收到警告
非法抵消“啞劇”
在以下代碼上:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$conn = mysql_connect("localhost","root","");
$db = mysql_select_db("imagestore",$conn);
if(!$db)
{
echo mysql_error();
}
$rollNo = $_POST['rollNo'];
$image = addslashes (file_get_contents($_FILES['image']['tmp_name']));
$image_s=getimagesize($_FILES['image']['tmp_name']);
$imgtype = $image['mime'];
$q = "INSERT INTO students VALUES('','$rollNo','$image','$imgtype')";
$r=mysql_query($q,$conn);
if($r)
{
echo "Information stored successfully";
}
else
{
echo mysql_error();
}
?>
怎么解決呢?
錯別字。 獲取啞劇信息時,您使用了錯誤的變量名。 用$ image_s代替$ image [mime]; getimagesize()提供mime信息。
$image_s = getimagesize($_FILES['image']['tmp_name']);
$imgtype = $image_s['mime'];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.