我想添加一些功能来下载前几天上传的文件。我不方便使用 php,所以我不知道如何为所有列出的文件添加函数和生成链接。
这是我的php代码:-
// Destination folder for downloaded files
$date = date('m.d.y');
mkdir("uploads/" . $date, 0777, true);
$upload_folder = 'uploads/' . $date;
// If the browser supports sendAsBinary () can use the array $ _FILES
if(count($_FILES)>0) {
if( move_uploaded_file( $_FILES['upload']['tmp_name'] , $upload_folder.'/'.$_FILES['upload']['name'] ) ) {
echo 'done';
}
exit();
} else if(isset($_GET['up'])) {
// If the browser does not support sendAsBinary ()
if(isset($_GET['base64'])) {
$content = base64_decode(file_get_contents('php://input'));
} else {
$content = file_get_contents('php://input');
}
$headers = getallheaders();
$headers = array_change_key_case($headers, CASE_UPPER);
if(file_put_contents($upload_folder.'/'.$headers['UP-FILENAME'], $content)) {
echo 'done';
}
exit();
}