I'm having a browser problem only in IE9, which occurs when I load an attachment and when I click the Add Attach (POST) button, as picture below:
functionuploadResponse(frameId){$.ajax({type:"POST",
url: "/Turma/AtualizarGridAnexo",
success: function (data) {
$("#divGridAnexo").html(data);//Fill div with results
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr);
alert(ajaxOptions);
alert(thrownError);
}
});
}
$("#adicionarAnexo").click(function (e) {
var fileInput = $('#idAnexo');
var maxSize = 5000000; //colocar valor em bytes
var fname = $('#idAnexo[type=file]');
console.log(fileInput.get(0).files[0].size);
//pega o tamanho do arquivo
if (fileInput.get(0).files.length) {
var fileSize = fileInput.get(0).files[0].size;
//verifica se é maior que 5MB
if (fileSize > maxSize) {
alert('Este arquivo é muito grande para ser anexado. Limite máximo permitido: 5MB.');
return false;
}
//verifica se a extensão do arquivo é permitida
var fileName = $('input[type=file]').val().toUpperCase();
var regex = new RegExp("(.*?)\.(PDF|XLS|XLSX|DOC|DOCX|PPT|PPTX|MP3|WMA|AVI|PNG|JPG)$");
if (!(regex.test(fileName))) {
$('input[type=file]').val('');
alert('Extensão não permitida, as extensões permitidas são: PDF, XLS, XLSX, DOC, DOCX, PPT, PPTX, MP3, WMA, AVI, PNG e JPG');
return false;
}
//se o tamanho e a extensão for correta, faz upload do arquivo
else {
var tempFrame = document.createElement("iframe");
tempFrame.src = "";
tempFrame.onload = uploadResponse.bind(this, tempFrame);
tempFrame.name = "tmpFrameUpload"
this.appendChild(tempFrame);
this.form.target = tempFrame.name;
this.form.name = "uploadForm";
this.form.acceptCharset = "UTF-8";
//This is an example of a hidden input, used to pass extra vars to the server. Add more if you need them.
//var tempNodePath = document.createElement("input");
//tempNodePath.type = "hidden";
//tempNodePath.value = [dir]; //if you want specify a target path.
//tempNodePath.name = "filePath";
//this.form.insertBefore(tempNodePath, this.form.childNodes[0]);
this.form.submit();
jq.idAnexo.val('');
}
} else {
return false;
}
});
The error occurs in console.log (fileInput.get (0) .files [0] .size);
Can anyone help me? I already searched for this but did not find anything like it ...
Thanks in advance!