Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取完整路径并将其存储在变量中_Php - Fatal编程技术网

Php 如何获取完整路径并将其存储在变量中

Php 如何获取完整路径并将其存储在变量中,php,Php,我想创建一个程序,上传一个文件,无论它在文件中是什么,我都会通过使用textarea输出它。但我的问题是,由于浏览器的安全性,我无法获取上传文件的完整路径。我试着用它作为参考,但它只显示了伪造的路径。主要的问题是我无法获得将其存储在变量中的完整路径。你知道怎么做吗 我用这个代码来获取文件名 <?php if(isset($_POST['btnSubmit'])) { $fileName = $_POST['file'];

我想创建一个程序,上传一个文件,无论它在文件中是什么,我都会通过使用textarea输出它。但我的问题是,由于浏览器的安全性,我无法获取上传文件的完整路径。我试着用它作为参考,但它只显示了伪造的路径。主要的问题是我无法获得将其存储在变量中的完整路径。你知道怎么做吗

我用这个代码来获取文件名

<?php      
        if(isset($_POST['btnSubmit']))
        {
        $fileName = $_POST['file']; 
        $fullPath = (realpath).$fileName;

        --here there must be a variable that will hold the fullpath but the $fullPath is wrong way to declare.

        echo $fullPath."\n\n";
        }
        ?>


Err,它不只是在
$\u文件['field\u name']['tmp\u name']
中吗?如上所述,您使用$\u文件数组中的be tmp\u名称,然后设置要保存到的位置。您不需要路径,只需要文件名本身