带变量的多文件上传php
我在用PHP从同一页面上传多个文件时遇到了一些问题 这是我的设置:带变量的多文件上传php,php,html,file-upload,Php,Html,File Upload,我在用PHP从同一页面上传多个文件时遇到了一些问题 这是我的设置: <input type='file' name='file1'></input> <input type='file' name='file2'></input> <input type='file' name='file3'></input> <input type='file' name='file4'></input> 我
<input type='file' name='file1'></input>
<input type='file' name='file2'></input>
<input type='file' name='file3'></input>
<input type='file' name='file4'></input>
我需要的是用于sql查询的fileX,以便将其连接到该输入
我在这个案子里试过循环
for(x=1, x<=4, x++){
if($_FILES['file'.x][error] == 0){
upload
}
}
for(x=1,x只需将[]放在名称的末尾。
像
多数组文件[][您的_id]
if(!empty($_FILES) {
foreach($_FILES as $value)
// stuff to upload
// stuff to save in db
}
}
}
链接
上传的代码是什么?你的完整表单是什么样子的?然后做一个var_转储($_文件)并发布结果。是的,我知道,但是如果我的文件id(x)开始是8-12,…那么我使用文件id进行查询。我想使用“file1-x”中的数字作为插入sql数据库的变量,然后使用多个数组文件[][你的id]好的,我真的想不起来,但我会试试。看起来像是我要找的东西!谢谢你可以使用像print\u r()
,var\u dump()
这样的方法来跟踪你在任何步骤收到的值,调试你的代码。别忘了放一个die()
如果要停止脚本执行并查看实际接收到的内容,请在这些方法之后执行。
if(!empty($_FILES) {
foreach($_FILES as $value)
// stuff to upload
// stuff to save in db
}
}
}