可以使用 HTML 中的 accept 属性来设置上传文件的类型。例如,如果希望用户只能上传图像文件,可以使用以下代码: <form> <input type="file" accept="image/*"> </form>