支持新版的chrome内核webview才支持,抖音的webview内核部分手机机型不支持,可以通过js动态获取上传文件的后缀来判断
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>File Input Example</title> </head> <body> <input type="file" id="fileInput"> <p id="fileInfo"></p> <script> document.getElementById('fileInput').addEventListener('change', function(event) { const file = event.target.files[0]; if (file) { const fileName = file.name; const fileSize = file.size; const fileType = fileName.split('.').pop().toLowerCase(); // 检查文件后缀 const allowedExtensions = ['jpg', 'jpeg', 'png', 'gif']; if (!allowedExtensions.includes(fileType)) { document.getElementById('fileInfo').textContent = '不支持的文件类型'; return; } // 检查文件大小(例如,限制在 5MB 以内) const maxSize = 5 * 1024 * 1024; // 5MB if (fileSize > maxSize) { document.getElementById('fileInfo').textContent = '文件大小超过限制'; return; } // 显示文件信息 document.getElementById('fileInfo').textContent = `文件名: ${fileName}, 文件类型: ${fileType}, 文件大小: ${fileSize} bytes`; } else { document.getElementById('fileInfo').textContent = '未选择文件'; } }); </script> </body> </html>
网友回复
python如何调用openai的api实现知识讲解类动画讲解视频的合成?
html如何直接调用openai的api实现海报可视化设计及文本描述生成可编辑海报?
f12前端调试如何找出按钮点击事件触发的那段代码进行调试?
abcjs如何将曲谱播放后导出mid和wav格式音频下载?
python如何将曲子文本生成音乐mp3或wav、mid文件
python中mp3、wav音乐如何转成mid格式?
js在HTML中如何将曲谱生成音乐在线播放并下载本地?
python如何实现在windows上通过键盘来模拟鼠标操作?
python如何给win10电脑增加文件或文件夹右键自定义菜单?
python如何将音乐mp3文件解析获取曲调数据?