Import: verify file size in browser
This commit is contained in:
parent
b62b0b9b29
commit
cef5cc1244
10
js/main.js
10
js/main.js
@ -222,7 +222,13 @@ function exportFile(type, userid, trackid) {
|
|||||||
window.location.assign(url);
|
window.location.assign(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function importFile(input){
|
function importFile(input) {
|
||||||
|
var form = input.parentElement;
|
||||||
|
var sizeMax = form.elements['MAX_FILE_SIZE'].value;
|
||||||
|
if (input.files && input.files.length == 1 && input.files[0].size > sizeMax) {
|
||||||
|
alert(sprintf(lang['isizefailure'], sizeMax));
|
||||||
|
return;
|
||||||
|
}
|
||||||
var xhr = getXHR();
|
var xhr = getXHR();
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState == 4 && xhr.status == 200) {
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||||
@ -249,7 +255,7 @@ function importFile(input){
|
|||||||
}
|
}
|
||||||
// FIXME: show progress
|
// FIXME: show progress
|
||||||
xhr.open("POST", "utils/import.php", true);
|
xhr.open("POST", "utils/import.php", true);
|
||||||
xhr.send(new FormData(input.parentElement));
|
xhr.send(new FormData(form));
|
||||||
input.value = "";
|
input.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,5 +118,6 @@ $lang["import"] = "Import track";
|
|||||||
$lang["iuploadfailure"] = "Uploading failed";
|
$lang["iuploadfailure"] = "Uploading failed";
|
||||||
$lang["iparsefailure"] = "Parsing failed";
|
$lang["iparsefailure"] = "Parsing failed";
|
||||||
$lang["idatafailure"] = "No track data in imported file";
|
$lang["idatafailure"] = "No track data in imported file";
|
||||||
|
$lang["isizefailure"] = "The uploaded file size should not exceed %d bytes"; // substitutes number of bytes
|
||||||
$lang["imultiple"] = "Notice, multiple tracks imported (%d)"; // substitutes number of imported tracks
|
$lang["imultiple"] = "Notice, multiple tracks imported (%d)"; // substitutes number of imported tracks
|
||||||
?>
|
?>
|
||||||
|
@ -113,5 +113,6 @@ $lang["import"] = "Importuj trasę";
|
|||||||
$lang["iuploadfailure"] = "Błąd przesyłania pliku";
|
$lang["iuploadfailure"] = "Błąd przesyłania pliku";
|
||||||
$lang["iparsefailure"] = "Błąd parsowania pliku";
|
$lang["iparsefailure"] = "Błąd parsowania pliku";
|
||||||
$lang["idatafailure"] = "Brak trasy w importowanym pliku";
|
$lang["idatafailure"] = "Brak trasy w importowanym pliku";
|
||||||
|
$lang["isizefailure"] = "Wielkość importowanego pliku nie może przekraczać %d bajtów";
|
||||||
$lang["imultiple"] = "Uwaga, zaimportowano kilka tras (%d)";
|
$lang["imultiple"] = "Uwaga, zaimportowano kilka tras (%d)";
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user