我正在尝试从服务器的压缩文件夹中下载多个文件。以下是迄今为止我掌握的代码:
HTML
<form method="post">
<input type="checkbox" name="checked[]" value="<?php echo $path; ?>">
<input type="submit" name="download" value="Download Selected">
</form>
PHP:
if(isset($_POST[\'download\'])){
$files = $_POST[\'checked\'];
foreach ($files as $file ) {
if(file_exists($_SERVER[\'DOCUMENT_ROOT\'].\'/upload/folder/\'. $file)){
require_once(ABSPATH . "wp-admin" . \'/includes/file.php\');
$full_path = $_SERVER[\'DOCUMENT_ROOT\'].\'/bcg/wp-content/uploads/\'. $file;
download_url($full_path);
}
else {
echo \'file doesnt exist\';
}
}
}