gpt4 book ai didi

php - 多输入类型文件元素jquery ajax php mysql

转载 作者:行者123 更新时间:2023-11-29 22:19:33 24 4
gpt4 key购买 nike

我想在我的项目中放入 2 个输入类型文件,这意味着我希望能够在一个插入查询中上传两次。我正在寻找样本,但尚未找到。我找到的唯一相关文章是 this 但就是不多说。当我说多个输入文件时,我的意思是这样的。

<input type="file" name="file1"/> -first input file

<input type="file" name="file2"/> -second input file

我想要发生的是在一个输入文件中选择图像,然后再次在另一个输入文件中选择其他文件(例如 pdf),并能够将这些文件插入到单独的表中。我正在使用 ajax 将信息从 html 传递到我的服务器端。我使用 pdo(php),我的数据库是 mySQL。任何想法表示赞赏。有一个例子会很有帮助。特别是如何确定哪个$_filefrom which input file 。如果我可以确定这一点,我想我可以将它插入到服务器端的特定表中

UPDATE

如何从2个输入类型文件元素插入文件(两者都可以有多个文件)

最佳答案

Array
(
[file1] => Array
(
[name] => MyFile.txt (comes from the browser, so treat as tainted)
[type] => text/plain (not sure where it gets this from - assume the browser, so treat as tainted)
[tmp_name] => /tmp/php/php1h4j1o (could be anywhere on your system, depending on your config settings, but the user has no control, so this isn't tainted)
[error] => UPLOAD_ERR_OK (= 0)
[size] => 123 (the size in bytes)
)

[file2] => Array
(
[name] => MyFile.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php/php6hst32
[error] => UPLOAD_ERR_OK
[size] => 98174
)
)

来自here我希望这能解决我的问题

关于php - 多输入类型文件元素jquery ajax php mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30885836/

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