【发布时间】:2018-10-01 02:55:27
【问题描述】:
又是我。我在数据库中插入上传文件的名称时遇到问题。我已成功上传文件并且文件已移动到我想要的目录,谁能帮我弄清楚我的代码有什么问题?此外,我尝试对其进行一些回声,但我得到了“不成功”,并使数据库值可以为空。这是我的代码。
<?php
session_start();
include "../../3rdparty/engine.php";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if ($_SESSION['daya_user'] != '') {
if ($_FILES['dokumen']['name'] != "") {
//print_r($_POST);
$path = $_FILES['dokumen']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);
$nama_file = 'SO'.'-'.date("Ymd").'.'.$ext;
@copy($_FILES['dokumen']['tmp_name'], '../../dokumen_atk/'.$nama_file);
mysqli_query($con,"insert into tbl_atk (name_file) values ('$nama_file')");
header("location:../../index.php?mod=atk&submod=so_upload");
}
}
//header("location:../../index.php?mod=atk&submod=so_upload");
?>
【问题讨论】:
-
$_SESSION['daya_user']设置的时间和地点? -
@Geshode 用户登录系统时。
-
好吧,那么我们需要代码,因为它显然没有设置。
-
@Geshode 全部设置,我尝试了另一种形式,它运行顺利。
-
我刚刚意识到 else 属于第三个 if 而不是第一个。抱歉,我因为缩进弄糊涂了。