gpt4 book ai didi

php - php文件上传错误

转载 作者:行者123 更新时间:2023-11-28 03:58:00 24 4
gpt4 key购买 nike

我如何真正知道我是否通过文件上传选项将文件传递到服务器?

i) 我使用如下表格:

<form name = "someForm" id = "someForm" method = "post" action = "saveFile.php">                
<input type = "file" name = "upload1" id = "upload1" />
<input type = "file" name = "upload2" id = "upload2" />
<input type = "file" name = "upload3" id = "upload3" />
<input type = "submit" id = "btnSubmit" value = "Submit" />
</form>

ii) 在 saveFile.php 中,我使用:

说:

echo $_FILES['upload1']["size"]; 

与其他人不同,但我得到一个Undefined index: upload1 错误,但不是什么时候,我使用:

echo $_POST['upload1'];  //returns filename

最佳答案

您需要指定 <form>加密到"multipart/form-data" :

<form enctype = "multipart/form-data" name = "someForm" id = "someForm" method = "post" action = "saveFile.php">                
<input type = "file" name = "upload1" id = "upload1" />
<input type = "file" name = "upload2" id = "upload2" />
<input type = "file" name = "upload3" id = "upload3" />
<input type = "submit" id = "btnSubmit" value = "Submit" />
</form>

关于php - php文件上传错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8403177/

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