无法将上传的文档保存在文件目录中[解决]

发布于 2025-01-08 23:39:13 字数 1716 浏览 0 评论 0原文

我正在尝试上传文件并将其保存在目录中。我只能将其保存在数据库中,但不能保存在目录中。这是我正在使用的代码。

<?php
$uploadLocation = "document/";


 $uploadMainTo = null;
  $main_image_name = $_FILES['file_name']['name'];
  $main_image_size = $_FILES['file_name']['size'];
  $main_image_tmp = $_FILES['file_name']['tmp_name'];
  $uploadMainTo = $uploadLocation.$main_image_name;
  $moveMain = move_uploaded_file($main_image_tmp,$uploadMainTo);


if(isset($_POST["submit"]) && !empty($_FILES['file_name']['name'])){
    

    $s_name1 = $_POST['s_name1'];
    $s_num1 = $_POST['s_num1'];
    $s_dept1 = $_POST['s_dept1'];
    $s_phone1 = $_POST['s_phone1'];
    $s_lesen1 = $_POST['s_lesen1'];
    $datestart = $_POST['datestart'];
    $dateend = $_POST['dateend'];
    $destination = $_POST['destination'];
    $purpose = $_POST['purpose'];
  
echo $query = $conn->query("INSERT into book (book_type,s_name1,s_num1,s_dept1,s_phone1,s_lesen1,datestart,dateend,destination,purpose,file_name,status,created_by,update_by) VALUES ('Normal','".$s_name1."','".$s_num1."','".$s_dept1."','".$s_phone1."','".$s_lesen1."','".$datestart."','".$dateend."','".$destination."','".$purpose."','"$main_image_name."','Proses','".$user."', NOW())");
            if($query){
//                $statusMsg = "The file ".$fileName. " has been uploaded successfully.";
               
                echo "<script>";
                echo "<script>alert('Booking Application already send to PIC ')</script>";
                echo "<script>";
                echo "window.location.href = 'list_normal.php?id=$user'";
                echo "</script>";
                
}}?>

您好,只是想通知您,我已经通过调整系统文件夹属性和允许权限解决了这个问题。

i'm trying to upload file and save it in directory. i only able to save it in database but not in directory. here is the code that i'm using.

<?php
$uploadLocation = "document/";


 $uploadMainTo = null;
  $main_image_name = $_FILES['file_name']['name'];
  $main_image_size = $_FILES['file_name']['size'];
  $main_image_tmp = $_FILES['file_name']['tmp_name'];
  $uploadMainTo = $uploadLocation.$main_image_name;
  $moveMain = move_uploaded_file($main_image_tmp,$uploadMainTo);


if(isset($_POST["submit"]) && !empty($_FILES['file_name']['name'])){
    

    $s_name1 = $_POST['s_name1'];
    $s_num1 = $_POST['s_num1'];
    $s_dept1 = $_POST['s_dept1'];
    $s_phone1 = $_POST['s_phone1'];
    $s_lesen1 = $_POST['s_lesen1'];
    $datestart = $_POST['datestart'];
    $dateend = $_POST['dateend'];
    $destination = $_POST['destination'];
    $purpose = $_POST['purpose'];
  
echo $query = $conn->query("INSERT into book (book_type,s_name1,s_num1,s_dept1,s_phone1,s_lesen1,datestart,dateend,destination,purpose,file_name,status,created_by,update_by) VALUES ('Normal','".$s_name1."','".$s_num1."','".$s_dept1."','".$s_phone1."','".$s_lesen1."','".$datestart."','".$dateend."','".$destination."','".$purpose."','"$main_image_name."','Proses','".$user."', NOW())");
            if($query){
//                $statusMsg = "The file ".$fileName. " has been uploaded successfully.";
               
                echo "<script>";
                echo "<script>alert('Booking Application already send to PIC ')</script>";
                echo "<script>";
                echo "window.location.href = 'list_normal.php?id=$user'";
                echo "</script>";
                
}}?>

Hi, just want to inform that i already solve this problem by adjusting the system folder properties and allow permissions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文