且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP:一次上传多个图像到imgur

更新时间:2022-12-25 22:03:00

更改标记如下:

<form action="file-upload.php" method="post" enctype="multipart/form-data">
  Send these files:<br />
  <input name="file[]" type="file" multiple="multiple" /><br />
  <input type="submit" value="Send files" />
</form>

现在,您可以使用 foreach 遍历 $_FILES 数组,如下所示:

Now, you can loop through the $_FILES array using a foreach, like so:

foreach ($_FILES['file']['tmp_name'] as $index => $tmpName) {
    if( !empty( $tmpName ) && is_uploaded_file( $tmpName ) )
    {
        // $tmpName is the file
        // code for sending the image to imgur
    }
}