加入avif支持,修正date()函数出错

This commit is contained in:
sunson 2024-11-30 18:56:56 +08:00
parent fc53a73ecc
commit cfa8f0a48b
2 changed files with 7 additions and 4 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
o/*

View File

@ -23,7 +23,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
$file_tmp = $_FILES['file']['tmp_name'];
$error = $_FILES['file']['error'];
// 获取当前年月
// 获取当前年月,为防止报错,先设置时区
date_default_timezone_set('Asia/Shanghai');
$year_month = date('Y/m');
$upload_dir = $base_upload_dir . $year_month;
@ -223,7 +224,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
<form id="uploadForm" enctype="multipart/form-data">
<div class="mb-3">
<label for="files" class="form-label"></label>
<input type="file" class="form-control" id="files" name="files[]" multiple accept="image/jpeg, image/png, image/gif, image/webp, image/bmp, image/svg+xml" required>
<input type="file" class="form-control" id="files" name="files[]" multiple accept="image/jpeg, image/png, image/gif, image/webp, image/avif, image/bmp, image/svg+xml" required>
</div>
<button type="submit" class="btn btn-primary w-100" style="font-weight: bold;">开始上传</button>
</form>
@ -238,7 +239,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
<button class="btn btn-success" id="copyAllBtn">复制所有链接</button>
</div>
</div>
<h6 id="formatHint" class="card-title text-center">支持格式: JPEG, PNG, GIF, WEBP, BMP, SVG</h6>
<h6 id="formatHint" class="card-title text-center">支持格式: JPEG, PNG, GIF, WEBP, AVIF, BMP, SVG</h6>
</div>
</div>
</div>
@ -274,7 +275,7 @@ $(document).ready(function () {
clearOutput();
var files = this.files;
// 允许的文件类型
var validFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/bmp', 'image/svg'];
var validFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/avif', 'image/bmp', 'image/svg'];
var validFiles = Array.from(files).filter(file => validFormats.includes(file.type));
if (validFiles.length === 0) {