使用PHP将文件上传到路径时出现问题

时间:2019-08-07 14:13:25

标签: php

我无法使用move_uploaded函数将上传的文件移动到所需的路径。 请帮帮我。

我试图将语法更改为以下形式:-           $ destination_path = getcwd()。DIRECTORY_SEPARATOR;           $ target_path = $ destination_path。 basename($ _FILES [“ profpic” [“ name”]); 然后也做不到。

if(isset($_POST['otp-btn'])){


                   $otpa = $_POST['otp'];
                   $file_n = $_COOKIE['file_name'];


                  if($_COOKIE['otp'] ==  $otpa){

                                $destination = '/adhaar';


         if(!move_uploaded_file($_COOKIE['tmp'], "$destination/$file_n")){
            echo "<script>alert('File is not uploaded')</script>";
                                                        }
}

每个变量都在获取信息(诸如$ _COOKIE ['tmp'],$ file_n之类的变量)不为空。我回应了它,并传达了信息。

文件未上传。

1 个答案:

答案 0 :(得分:-1)

 if(isset($_POST['otp-btn'])){


                   $otpa = $_POST['otp'];
                   $file_n = $_COOKIE['file_name'];


                  if($_COOKIE['otp'] ==  $otpa){

                                $destination = './adhaar';


         if(!move_uploaded_file($_COOKIE['tmp'], "$destination/$file_n")){
            echo "<script>alert('File is not uploaded')</script>";
                                                        }
 }

尝试一下。