jQuery File Upload预览文件类型以允许所有文件类型 [英] JQuery File Upload preview File Type to allow all file types
问题描述
我正在尝试预览不同的文件类型,但无法正常工作.默认情况下,jQuery File upload仅预览图像文件(jpeg | png | gif).但是我需要显示其他文件类型的预览,例如(pdf | doc | pptx | txt).如何做到这一点? 我尝试更改此设置,但没有运气
I am trying to preview different file types, but Its not working. By default jQuery File upload only previews Image files(jpeg | png | gif). But I need to display a preview for Other File types such as (pdf | doc | pptx | txt). How to achive this?? I tried changing this, but no luck
现有代码:
previewFileTypes: /^image\/(gif|jpeg|png)$/,
我的更改:(仍然不显示pdf,doc,ppt的预览)
My Change: (Still does not show preview for pdf, doc, ppt)
previewFileTypes: /^.*\/(gif|jpeg|png|pdf|PDF|pptx|plain|doc|docx)$/,
推荐答案
预览用于显示图像. PDF和文档文件类型不是图像,因此无法显示.从文档:
The preview is for showing images. The PDF and document file types are not images, and cannot be shown. From the documentation:
预览图像,音频和视频:图像,音频和视频的预览 在使用支持以下功能的浏览器上传之前,可以显示文件 必需的API.
Preview images, audio and video: A preview of image, audio and video files can be displayed before uploading with browsers supporting the required APIs.
这篇关于jQuery File Upload预览文件类型以允许所有文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!