使用 PHP 上传两个文件 [英] Upload two files using PHP

查看:59
本文介绍了使用 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 上传两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆