php html中标识索引的问题
我的网站必须包括一个表格,管理员必须上传一些文件的页面。后来,php将该文件保存为mysql中的blob,但是,$\u文件无法找到我的文件输入并为其编制索引。请帮忙找个错误php html中标识索引的问题,php,html,sql,Php,Html,Sql,我的网站必须包括一个表格,管理员必须上传一些文件的页面。后来,php将该文件保存为mysql中的blob,但是,$\u文件无法找到我的文件输入并为其编制索引。请帮忙找个错误 <tr> <th>ID</th> <th>Genre</th> <th>Extension</th> <th>Description</th> <th>Dem
<tr>
<th>ID</th>
<th>Genre</th>
<th>Extension</th>
<th>Description</th>
<th>Demo-art</th>
<th>Price</th>
<th>Upload</th>
<th>Delete</th>
</tr>";
$array=array();
for($m=0; $row=mysqli_fetch_array($full); $m++)
{
$array[$m]=$row['ArtID'];
echo "<form method='POST' action='checker.php'>";
echo "<tr>";
echo "<td><input class='asd' value='$array[$m]' readonly name='name'></td>";
echo "<td>".$row['Genre']."</td>";
echo "<td>".$row['Extension']."</td>";
echo "<td>".$row['Description']."</td>";
echo "<td><input type='file' name='arts'></td>";
echo "<td><input class='priceinput' name='price' placeholder='Price'></td>";
echo "<td><input type='submit' name='Upload' value='Upload'></td>";
echo "<td><input type='submit' name='Delete' value='Delete'></td>";
echo "</tr>";
echo "</form>";
}
echo "</table>";
;}
身份证件
体裁
延伸
描述
演示艺术
价格
上传
删除
";
$array=array();
对于($m=0;$row=mysqli_fetch_数组($full);$m++)
{
$array[$m]=$row['ArtID'];
回声“;
回声“;
回声“;
回显“$row['Genre']”;
回显“$row['Extension']”;
回显“$row['Description']”;
回声“;
回声“;
回声“;
回声“;
回声“;
回声“;
}
回声“;
;}
PHP代码
session_start();
$conn= new mysqli("127.0.0.1", "root", "","projectwork") or die ("Can't connect to db");
if($_POST["Upload"]) {
$price=$_POST["price"];
$id=$_POST["name"];
if ($price!=NULL) {
if (is_uploaded_file($_FILES['arts']['tmp_name'])) {
$imgData = addslashes(file_get_contents($_FILES['arts']['tmp_name']));
$imageProperties = getimageSize($_FILES['arts']['tmp_name']);
$sql = "Update arts SET imageData='".$imgData."', imageType='".$imageProperties['mime']."' WHERE ArtID=".$id."";
$current_id = mysqli_query($conn, $sql) or die("<b>Error:</b> Problem on Image Insert<br/>" . mysqli_error($conn));
}
$insert="UPDATE arts SET Price='".$price."', Is_Done='1' WHERE ArtID=".$id."";
$finalquery=$conn->query($insert);
echo $price." ".$id;
}
session_start();
$conn=new mysqli(“127.0.0.1”、“root”、“projectwork”)或die(“无法连接到数据库”);
如果($_POST[“上载”]){
$price=$_POST[“price”];
$id=$_POST[“name”];
如果($price!=NULL){
如果(是上传的文件($文件['arts']['tmp\U名称]])){
$imgData=addslashes(文件获取内容($\u文件['arts']['tmp\u名称]]);
$imageProperties=getimageSize($_文件['arts']['tmp_名称]]);
$sql=“Update arts SET imageData=”“$imgData.”,imageType=”“$imageProperties['mime']”,其中ArtID=“.id.”;
$current_id=mysqli_query($conn,$sql)或die(“错误:插入图像时出现问题
”。mysqli_错误($conn));
}
$insert=“UPDATE arts SET Price=”“$Price.”,其中ArtID=“.id.”是否为“完成”='1';
$finalquery=$conn->query($insert);
echo$price.“$id;
}
除了代码中的安全缺陷之外,表单元素中还缺少enctype='multipart/form data'
尝试:
echo”“;
它会告诉浏览器您正在发送一个文件。警告!您完全有可能受到攻击!您应该使用参数化的用户数据,而不是像这样直接在查询中使用完全未经扫描的用户数据。永远不要信任用户输入。您应该将文件存储在目录中并保留文件引用(名称、路径等)改为在数据库中。您也不应该向用户/客户端显示来自
mysqli\u error()
的消息,因为它可能包含敏感数据。请记录错误消息并显示一般错误消息。
echo "<form method='POST' action='checker.php' enctype='multipart/form-data'>";