Skip to content

Commit

Permalink
Fix bug in max upload size error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Nov 21, 2023
1 parent 6424e86 commit 7bd4d17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion freesound/static/bw-frontend/src/pages/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var onFileInputChange = function onFileInputChange(event) {
showListOfSounds();
var percent_size = soundsQueue.reduce((acc, curr) => acc + curr.size, 0) * 100 / maxUploadSize;
setSizeBarValue(percent_size);
resetForm(num > 0 ? "Upload limit of {{ max_file_size_in_MB }} MB exceeded. " + num + " file" + (num > 1 ? "s" : "") + " discarded." : " ");
resetForm(num > 0 ? "Upload limit of " + maxUploadSizeInMB + " MB exceeded. " + num + " file" + (num > 1 ? "s" : "") + " discarded." : " ");
};

var addErrorListElement = function addErrorListElement() {
Expand Down Expand Up @@ -197,6 +197,7 @@ fileInput.style.display = 'none';
progressContainer.style.display = 'none';
abortButton.style.display = 'none';
var maxUploadSize = uploadForm.dataset.maxFileSize;
var maxUploadSizeInMB = uploadForm.dataset.maxFileSizeMb;

// drag and drop
document.addEventListener('dragenter', onDrag);
Expand Down
4 changes: 2 additions & 2 deletions templates/accounts/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ <h5>Moderation</h5>
<div class="col-md-6 col-lg-3">
<div class="padding-right-2">
<h5>Formats</h5>
<p>We prefer <strong>wav, aif and flac</strong>, but we support <strong>ogg</strong>, <strong>m4a</strong> and <strong>mp3</strong> too. For very large files please use some compressed format. Uploading more than 1GB at once might fail.</p>
<p>We prefer <strong>wav, aif and flac</strong>, but we support <strong>ogg</strong>, <strong>m4a</strong> and <strong>mp3</strong> too. For very large files please use some compressed format.</p>
</div>
</div>
</div>
<div class="row no-gutters v-spacing-4">
{% if uploads_enabled %}

<div class="col-md-6">
<form method="POST" enctype="multipart/form-data" class="html_upload_form" id="upload-form" data-max-file-size="{{ max_file_size }}" data-upload-url="{% url 'accounts-upload' %}">{% csrf_token %}
<form method="POST" enctype="multipart/form-data" class="html_upload_form" id="upload-form" data-max-file-size="{{ max_file_size }}" data-max-file-size-mb="{{ max_file_size_in_MB }}" data-upload-url="{% url 'accounts-upload' %}">{% csrf_token %}
{{ form.as_p }}

<div id="drag-tip">
Expand Down

0 comments on commit 7bd4d17

Please sign in to comment.