我正在尝试上传系统,它还会将您上传的文件的名称和其他一些数据记录到mysql数据库中。记录名称是有效的,但我似乎无法上传图像。它无处可寻=(
HTML:
<form action="insert.php" method="post" enctype='multipart/form-data'>
<td>Photo/Video of the mistake</td>
<td>
<input type="hidden" name="size" value="350000">
<input type="file" name="photo">
</td>
PHP
$con=mysqli_connect("127.0.0.1","erlend","123","epicsoft");
$host="127.0.0.1"; // Host name
$username="erlend"; // Mysql username
$password="123"; // Mysql password
$db_name="epicsoft"; // Database name
$tbl_name="bugs"; // Table name
$path="images/bugs"."/". basename($_FILES['photo']['name']);
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select database");
$spill = $_POST['spill'];
$tidspunkt = $_POST['tidspunkt'];
$rapportør = $_POST['rapportør'];
$beskrivelse = $_POST['beskrivelse'];
$media=($_FILES['photo']['name']);
$sql="INSERT INTO $tbl_name (spill, tidspunkt, rapportør, media, beskrivelse)
VALUES ('$spill', '$tidspunkt', '$rapportør', '$media', '$beskrivelse')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
感谢阅读!
答案 0 :(得分:0)
试试这个
$sql="INSERT INTO `$tbl_name` ( `spill`, `tidspunk`, `rapportør`, `media`, `beskrivelse`) VALUES ('$spill', '$tidspunkt', '$rapportør', '$media', '$beskrivelse');";