我需要有关如何制作react-dropzone NPM 包的帮助,以便让上传的文件在图像文件(*.png、*.jpg/jpeg、*.gif 等)以外的文件上显示预览——这些都只生成预览美好的)。
Currently, when I use Dropzone for uploading accompanying files on a web form, if I Upload an Image file (*.png, *.jpg, etc.), the Preview we have set up shows just fine with a small thumbnail of the Uploaded file. (see pic below)

However, if I upload another type of file, say an MS-Outlook *.docx, *.xlsx, or say an Adobe Acrobat *.pdf, it just gives me a blank box with a broken file image and whatever …
我继承了 AWS EC2 实例服务器上前端的 React.JS 和后端的 Node.JS/Express.JS 代码库。我使用的代码是react-dropzone(https://react-dropzone.js.org/),并且仅用于拖放图像文件。我正在处理的项目的产品所有者现在希望它接受所有文件(*.pdf、*.docx、*.xlsx 等)。
\n\n我想知道如何让它接受所有文件?我已经浏览了react-dropzone文档,但还没有找到任何示例来展示如何让它接受所有文件类型?就像设置accept="..."fromaccept="image/*"到一样简单吗accept="*/*"?字符串可以accept="..."是数组吗,例如:accept=["image/*","text/*",...]等?让react-dropzone接受任何文件类型的正确方法是什么?
onDrop这是我的回调 \xe2\x80\x94的代码
onDrop = (acceptedFiles, rejectedFiles) => {\n let files = acceptedFiles.map(async file => {\n let data = new FormData();\n data.append("file", file);\n\n let item = await axios\n .post("triage/upload", data, {\n headers: {\n "X-Requested-With": "XMLHttpRequest",\n "Content-Type": "application/x-www-form-urlencoded"\n }\n })\n .then(response => {\n return Object.assign(file, {\n preview: URL.createObjectURL(file),\n filename: response.data.filename\n …Run Code Online (Sandbox Code Playgroud)