gpt4 book ai didi

PHP HTML : File upload not working

转载 作者:太空狗 更新时间:2023-10-29 16:36:01 26 4
gpt4 key购买 nike

我不敢相信我必须问这个问题,但出于某种原因我的文件无法正常工作。它叫做 ajax.php(尽管不要介意这个名字),这里是确切的代码:

<?php
error_reporting(-1);

print_r($_POST);
print_r($_FILES);
?>

<form action="ajax.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input type="text" name="first" value="Bob" />
<input type="text" name="middle" value="James" />
<input type="text" name="last" value="Smith" />
<input type="file" name="something" />
<input type="submit" value="Submit" />
</form>

当我在没有附加文件的情​​况下提交时,它会在数组中打印数据。当我使用文件提交时,不会填充任何数组。

我错过了什么明显的东西???

没有文件

Array ( [MAX_FILE_SIZE] => 30000 [first] => Bob [middle] => James [last] => Smith )
Array ( [something] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )

带文件

Array ( )
Array ( )

文件预期

Array ( [MAX_FILE_SIZE] => 30000 [first] => Bob [middle] => James [last] => Smith )
Array ( [something] => Array ( [name] => sample.jpg [type] => image/jpg [tmp_name] => whatever.jpg [error] => 0 [size] => 1248 ) )

更新

它似乎在另一台服务器上工作,它肯定是我的 WAMP 的一些配置,这意味着我的问题被错误地提出,因此我将关闭它。向因我的愚蠢而浪费时间的任何人道歉。

最佳答案

这似乎是一个配置问题。我会说 post_max_size太小。这可以解释为什么上传文件时 $_POST 超全局变量是空的。从手册...

If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty.

您需要将此值设置为大于 upload_max_filesize。例如,我的一台服务器有...

file_uploads=On
upload_max_filesize=12M
post_max_size=20M

关于PHP HTML : File upload not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26856270/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com