使用 php 上传图片导致 accept-file.php was not found
Uploading image using php results in accept-file.php was not found
您好,我正在尝试使用 php 将图像上传到数据库,但每次我按下提交按钮时,我都会收到错误消息
接受-file.php 未找到
我在我的代码中没有看到它指向的任何地方,我是否遗漏了什么?
<?php
session_start();
$link = mysqli_connect("localhost","root","","pictureupload");
if(isset($_POST['submit'])){
$imagename=$_FILES["iamge"]["name"];
$imagetmp=addslashes (file_get_contents($_FILES['image']['tmp_name']));
$insert_image="INSERT INTO images VALUES('$imagetmp','$imagename')";
mysqli_query($link,$insert_image);
}
?>
<!DOCTYPE html>
<html>
<head>
<Title>HomePage</Title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form action="accept-file.php" method="post" enctype="multipart/form-data">
Your Image: <input type="file" name="image" size="25" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
将您的表单标签更改为
<form action="?"
您的表单已 "accept-file.php" 设置为操作:
<form action="accept-file.php" method="post" enctype="multipart/form-data">
这是通过设置方法(在本例中为POST)并使用给定编码类型将表单数据发送到的位置。
点击 "submit" 后,您的浏览器将调用此脚本,在您的情况下该脚本不存在。因此,您的网络服务器将 return 错误消息而不是处理上传。
要使其正常工作,您需要将操作更改为您在上面发布的脚本的文件名。
您好,我正在尝试使用 php 将图像上传到数据库,但每次我按下提交按钮时,我都会收到错误消息
接受-file.php 未找到
我在我的代码中没有看到它指向的任何地方,我是否遗漏了什么?
<?php
session_start();
$link = mysqli_connect("localhost","root","","pictureupload");
if(isset($_POST['submit'])){
$imagename=$_FILES["iamge"]["name"];
$imagetmp=addslashes (file_get_contents($_FILES['image']['tmp_name']));
$insert_image="INSERT INTO images VALUES('$imagetmp','$imagename')";
mysqli_query($link,$insert_image);
}
?>
<!DOCTYPE html>
<html>
<head>
<Title>HomePage</Title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form action="accept-file.php" method="post" enctype="multipart/form-data">
Your Image: <input type="file" name="image" size="25" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
将您的表单标签更改为
<form action="?"
您的表单已 "accept-file.php" 设置为操作:
<form action="accept-file.php" method="post" enctype="multipart/form-data">
这是通过设置方法(在本例中为POST)并使用给定编码类型将表单数据发送到的位置。
点击 "submit" 后,您的浏览器将调用此脚本,在您的情况下该脚本不存在。因此,您的网络服务器将 return 错误消息而不是处理上传。
要使其正常工作,您需要将操作更改为您在上面发布的脚本的文件名。