首页 > 解决方案 > 我想将文件存储到两个不同的文件夹位置,但它显示错误

问题描述

这是我编写的将数据分别存储到两个文件夹中的代码,但它显示错误,或者有人可以纠正我以帮助我。还有另一种方法可以将数据存储到不同的文件夹中吗?Parse error: syntax error, unexpected '$folder1' (T_VARIABLE) in C:\xampp\htdocs\scienceworld\admin\code.php on line 91它在 move_uploaded_files 之后显示此错误。

if(isset($_POST['add_maths']))

{
    $title = $_POST['title'];
    $description = $_POST['description'];
    $datatype = $_POST['datatype']; // here i define two values PDF and Video
    $files = $_FILES["content"]['name'];

    $ext = pathinfo($files, PATHINFO_EXTENSION);

    if ($ext == '.Application') 
     {
        $folder = "upload/PDF/";
     } 
     else 
     {  $ext == '.Video';//you can add allowed video extensions here
        $folder1 = "upload/";     (here it shows error)
     }


    if(file_exists($folder||$folder1.$_FILES["content"]['name']))
      {
          $store = $_FILES["content"]['name'];
          $_SESSION['status'] = "File Already Exist. '.$store.'";
          header('Location: 8thmaths.php');
      }
    else
    {
        $query = "INSERT INTO 8maths (title,description,datatype,files) VALUES ('$title','$description','$datatype','$files')";
        $query_run = mysqli_query($connection, $query);
        
         if($query_run)
            {
                // echo "Saved";
                 move_uploaded_file($_FILES["content"]['tmp_name'], ($folder,$folder1.$_FILES["content"]['name']);
                $_SESSION['success'] = "Data is Added";
                header('Location: 8thmaths.php');
            }
         else 
            {
                 $_SESSION['status'] = "Data is Not Added";
                 header('Location: 8thmaths.php');  
            }
    }
}

标签: php

解决方案


推荐阅读