Upload two files using PHP(使用 PHP 上传两个文件)
问题描述
我知道这听起来可能比较基本的问题,但还是想问.我需要通过在我的表单中为每个文件创建两个文件输入来一次上传两个文件.到目前为止,我一直使用一个基本脚本来测试上传单个文件.
I know this may sound relatively basic question, but still wanted to ask. I need to upload two files at once by creating two file input in my form one for each file. Until now I have used a basic script for testing to upload a single file.
我还找到了一些如何上传多个文件的示例,但就我而言,我有两个上传字段,我希望用户上传这两个文件.上传后,我想将其保存在我的网络服务器上.任何简单的例子都会有很好的帮助.
I also found some examples how to upload muliple files, but in my case I am having two upload fields and I want the user to upload the two files. Once uploaded I wanted to save it onmy webserver. Any simple example would be of good help.
谢谢
推荐答案
这只是一个简单的情况,只是改变了变量名,然后把所有的事情都做了两次.
It's simply just a case of changing the variable names and doing everything twice.
HTML:
<input type="file" name="filea" />
<input type="file" name="fileb" />
PHP:
$filea = $_FILES['filea'];
$fileb = $_FILES['fileb'];
move_uploaded_file($filea['tmp_name'], '/path/to/your/destination/'.$filea['name']);
你能从那里继续吗?
这篇关于使用 PHP 上传两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 PHP 上传两个文件
基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
