简体   繁体   English

使用PHP将文件上传到路径的问题

[英]Problem in Uploading file to path using PHP

I'm not unable to move the uploaded file to the desired path using move_uploaded function.我无法使用 move_uploaded 函数将上传的文件移动到所需的路径。 Please help me out.请帮帮我。

I tried to change my syntax to something like this:- $destination_path = getcwd().DIRECTORY_SEPARATOR;我试图将我的语法更改为这样的:- $destination_path = getcwd().DIRECTORY_SEPARATOR; $target_path = $destination_path . $target_path = $destination_path 。 basename( $_FILES["profpic"["name"]); basename($_FILES["profpic"["name"]); Then also couldn't do it.然后也做不到。

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>";
                                                        }
}

Every variable is fetching information(variables such as $_COOKIE['tmp'], $file_n) are not empty.每个变量都在获取信息($_COOKIE['tmp'], $file_n 等变量)不为空。 I echoed it and it was carrying the information.我回应了它,它携带着信息。

File is not getting uploaded.文件未上传。

 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>";
                                                        }
 }

Try this.尝试这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM