Dropzone file upload component not working #101
-
So I have tried to use the drag and drop example provided in the File Upload component page. It just straight up doesn't want to work. Looking in the console I get this:
I have all the scripts in my Layout.astro file: <script src="../../node_modules/flatpickr/dist/flatpickr.js"></script>
<script src="../../node_modules/flyonui/flyonui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
<script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js" ></script> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @telumletiferum , Hi! 👋 The error you're seeing: Uncaught SyntaxError: JSON.parse: expected ',' or '}' …usually means there's an issue with how the JSON is written in your In Astro, when passing JSON with double quotes (like inside an SVG string), you must escape those quotes using ✅ Here's how to fix it:
This ensures the JSON remains valid and JSON.parse() won't throw an error. |
Beta Was this translation helpful? Give feedback.
Hello @telumletiferum ,
Hi! 👋 The error you're seeing:
…usually means there's an issue with how the JSON is written in your
data-file-upload
attribute.In Astro, when passing JSON with double quotes (like inside an SVG string), you must escape those quotes using
\\"
and wrap with data-file-upload={` .... `} — because the string is being interpreted as JavaScript inside a JSX-like expression. If you don't escape them, the browser can't parse it correctly.✅ Here's how to fix it: