Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.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
can';找不到什么';我的php上传程序有什么问题吗_Php_Html_Upload - Fatal编程技术网

can';找不到什么';我的php上传程序有什么问题吗

can';找不到什么';我的php上传程序有什么问题吗,php,html,upload,Php,Html,Upload,我正试图得到一个php上传脚本的工作。但是我不知道为什么$u文件看起来是空数组?有人能解释一下我下面的脚本出了什么问题吗 它假定将任意文件上载到/var/www/test/folder。。。 选择要上载的图像: 不要转储$\u文件我从未转储过它,对我来说很好。 尝试这段代码,将php放入另一个文件中,将表单重定向到该文件并添加此行 在脚本的末尾 最后的代码是: 它现在应该可以工作了。您的缺少enctype=“multipart/form data”中的=,而且最重要的是,它只是盲

我正试图得到一个php上传脚本的工作。但是我不知道为什么$u文件看起来是空数组?有人能解释一下我下面的脚本出了什么问题吗

它假定将任意文件上载到/var/www/test/folder。。。

选择要上载的图像:




不要转储$\u文件我从未转储过它,对我来说很好。 尝试这段代码,将php放入另一个文件中,将表单重定向到该文件并添加此行 在脚本的末尾


最后的代码是:



它现在应该可以工作了。

您的
缺少
enctype=“multipart/form data”
中的
=
,而且最重要的是,它只是盲目地假设成功并向前走,尽管PHP试图给您提供的所有证据表明事情确实失败了,而您完全忽略了这一点*在执行任何其他操作之前,请始终检查$\u文件中的
['error']
参数。
<html>
<body>
<?php
    if (isset($_POST['Submit'])) {

            $target_path = "/var/www/test/";
            $target_path = $target_path . basename($_FILES['myupload']['name']);

            if(!move_uploaded_file($_FILES['myupload']['tmp_name'], $target_path)) {

                echo '<pre>';
                print 'The $_FILES content is :';
                print_r($_FILES);
                var_dump($_FILES);
                echo '<pre>';
                print 'the target path is:' . $target_path;
                echo '<pre>';
                print 'the $_POST variable content is :';
                print_r($_POST) ;
                echo '<pre>';
                echo 'Your image was not uploaded.';
                echo '</pre>';

              } else {

                echo '<pre>';
                echo $target_path . ' succesfully uploaded!';
                echo '</pre>';

            }

        }
?>

<form method="POST" action="" enctype"multipart/form-data">
        Choose an image to upload:
        <br>
        <input type="file" name="myupload">
        <br>
        <br>
        <input type="submit" value="Upload(This_is_just_button_name_display)" name="Submit">
</form>
</body>
</html>
<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=samplehtml.html">
<?php
    if (isset($_POST['Submit'])) {

            $target_path = "/var/www/test/";
            $target_path = $target_path . basename($_FILES['myupload']['name']);

            if(!move_uploaded_file($_FILES['myupload']['tmp_name'], $target_path)) {

                echo '<pre>';
                print 'The $_FILES content is :';
                print_r($_FILES)
                echo '<pre>';
                print 'the target path is:' . $target_path;
                echo '<pre>';
                print 'the $_POST variable content is :';
                print_r($_POST) ;
                echo '<pre>';
                echo 'Your image was not uploaded.';
                echo '</pre>';

              } else {

                echo '<pre>';
                echo $target_path . ' succesfully uploaded!';
                echo '</pre>';

            }

        }
?>