我在实习中做的练习涉及一个上传页面,一个表格页面,它将输出数据库表的记录和一个数据库表。问题是,经过巨大的努力使所有连接良好,我遇到了一些麻烦,因为 index.php 页面应该发送信息并且正在发送数组并保存数组而不是文件。下面是 index.php 页面的 PHP 代码:
<?php
if (!isset($_POST['Enviar'])): // This if will search if the $_POST variable already has anything
or not.
$allowed = array('txt'); //This array contains the file types which are allowed.
$uploadtime = time();
$uploadfile = $_FILES['file_to_upload'];
include 'db_connection.php';
$sql="select * from uploads";
$result = $conn->query($sql);
$target_dir = "uploads/"; //variable that will save the name of the folder or way where the file
will be saved.
$target_file = $target_dir . basename($_FILES['file_to_upload']['name']); //NOTICE undefined index:
file_to_upload... because it doesn't have any value safe there yet.
$goon = 1; //This variable is used to check if there is any error messages or if the program can go
on.
$ext = pathinfo( $_FILES["file_to_upload"]["name"], PATHINFO_EXTENSION); // This will use the OS to
get the file extension.
if(!in_array($ext,$allowed) ) {
echo 'Erro: Ficheiro não permitido. <br> Por favor, verifique se o formato do ficheiro é txt.';
$goon = 0;
}
第二段代码中的字段名称是数据库中的名称。谁能告诉我在 index.php 页面中收到此错误消息有什么问题:注意:第 66 行 C:\xampp\htdocs\16082019\index.php 中的数组到字符串转换
撒科打诨
ABOUTYOU