Import: verify file size in browser
This commit is contained in:
parent
b62b0b9b29
commit
cef5cc1244
@ -223,6 +223,12 @@ function exportFile(type, userid, trackid) {
|
||||
}
|
||||
|
||||
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();
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||
@ -249,7 +255,7 @@ function importFile(input){
|
||||
}
|
||||
// FIXME: show progress
|
||||
xhr.open("POST", "utils/import.php", true);
|
||||
xhr.send(new FormData(input.parentElement));
|
||||
xhr.send(new FormData(form));
|
||||
input.value = "";
|
||||
}
|
||||
|
||||
|
@ -118,5 +118,6 @@ $lang["import"] = "Import track";
|
||||
$lang["iuploadfailure"] = "Uploading failed";
|
||||
$lang["iparsefailure"] = "Parsing failed";
|
||||
$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
|
||||
?>
|
||||
|
@ -113,5 +113,6 @@ $lang["import"] = "Importuj trasę";
|
||||
$lang["iuploadfailure"] = "Błąd przesyłania pliku";
|
||||
$lang["iparsefailure"] = "Błąd parsowania 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)";
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user