<script type="text/javascript"> Dropzone.autoDiscover = false;…
- User
- Assistant
As an AI language model, I can understand that this is a piece of JavaScript code that initializes a dropzone element and defines its configurations for uploading files with a specific format. The code sets the URL for sending the uploaded files, enables/disables the add/remove links, and sets the maximum file size and number of files allowed to be uploaded. Additionally, it handles the successful upload event and updates the download button with the downloaded file's URL, making it available for the user to download.
- User
why it doesn't work
- Assistant
As an AI language model, I can see that there are two issues in the code that may cause it not to work:
-
There is a syntax error in the configuration of the
dropzoneelement. TheaddRemoveLinksandparamNameoptions should be separated by a comma, but there is no comma between them. To fix this, add a comma afteraddRemoveLinks: true. -
The script is referencing the
URLobject, which should be capitalized aswindow.URL. To fix this, changeURLtowindow.URLin thesuccessevent handler.
Once these issues are addressed, the code should work properly.
-
- User
I have next coder on backend
- Assistant
Without seeing your code, I'm not sure what you mean by "next coder on backend". Could you please share your code or provide more information about what you're trying to accomplish? As an AI language model, I'll do my best to assist you.
- User
- Assistant
Thank you for sharing your code. From what I see, the Dropzone initialization script seems to be okay, except for a typo in the
successevent handler. Theurlproperty should beURLinstead ofurl. Please change this:$("#download-multiple").prop("href", url.createObjectURL(response));To this:
$("#download-multiple").prop("href", URL.createObjectURL(response));Additionally, I noticed that the target language list is not being sent to the backend. To fix this, you need to add the name attribute to the select element. Change this:
<select id="target_lang_list" name="target_lang_list[]" class="selectpicker" multiple data-live-search="true" required>To this:
<select id="target_lang_list" name="target_lang_list" class="selectpicker" multiple data-live-search="true" required>The
nameattribute should match the name of the parameter in the backend. The[]is unnecessary since this is already a multiple select element.Lastly, make sure that you have added the necessary CSS and JavaScript files for and libraries to work properly.
- User
why my dropzone inactive
- Assistant
Based on the code you've provided, I think the issue may be related to the fact that you're using an id
my-dropzoneto define the dropzone element, but the class you've assigned to it isdropzone. You should change this:<div id="my-dropzone" class="dropzone"></div>To this:
<div class="dropzone" id="my-dropzone"></div>This way, you'll be assigning the
dropzoneclass to the element, which allowsDropzoneto recognize it as an element that it should control.Additionally, as I mentioned in my previous response, you need to add the necessary CSS and JavaScript files for
Dropzonelibrary to work properly. You can add these lines in the<head>section of your HTML:<link rel="stylesheet" href="https://unpkg.com/dropzone@5/dist/min/dropzone.min.css" type="text/css" /> <script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js"></script>These lines import the CSS and JavaScript files for the
Dropzonelibrary from theunpkg.comCDN.With these changes, your dropzone element should be active and functional. Let me know if you have any further issues!
- User
no, it still doesn't work
- Assistant
I'm sorry to hear that the changes did not fix the issue. Without seeing the full code and seeing what's happening in the browser's console, it's difficult to determine what the issue might be. However, here are a few more suggestions you can try:
-
Make sure that the
Dropzonelibrary is being loaded correctly. You can check the browser's console for any errors related to theDropzonelibrary.
-