Upload multiple PHP files

I saw this example on documentation for PHP readfile

<?php
$file = 'monkey.gif';

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
?>

How can you do this to upload multiple say monkey.gifand filesgirraffe.jpg

Preferably without ZIP files ...

+3
source share
2 answers

You can not. This is not a limitation of PHP, it is a limitation of HTTP / Web-Browser. HTTP does not provide a mechanism for sending multiple files on a single request.

However, you may have some PHP script that generates several frames that will run one load each and fake it this way.

+7
source

, . JavaScript, URL- , .htaccess, .

-

<script> var files = ['filename1.jpg', 'filename2.jpg']; for (var i = files.length - 1; i >= 0; i--) { var a = document.createElement("a"); a.target = "_blank"; a.download = "download"; a.href = 'http://www.example.com/path_to/images/' + files[i]; a.click(); }; </script>

+2

Source: https://habr.com/ru/post/1606731/


All Articles