Hi everyone, I have an application that sends files through the request of a form. I’m having a somewhat peculiar problem with the iPhone, when I try to send a video that is in the gallery, it sends the form without the video, as if it had not selected anything. But this only happens when the file is a video that is in the gallery, when it is a video recorded at the time, it sends normally. It was tested on the iPhone iOS 9 and iOS 10. But what intrigues more is that when it is tested in the Xcode VM the form submits normally.
In Android is working normally.
Would anyone know why it was not working and how to solve it?
Sorry for my english, I had to use google translate.
Can you post some code of your form?
Html file
<form name="form1" id="form1" action="http://52.67.25.71:8080/pop3web.90.3.java.arquivos/FileUpload" enctype="multipart/form-data" method="post">
<div id="escoder">
<input type="text" name="idClube" id="idClube">
<input type="text" name="idUsuario" id="idUsuario">
<input type="text" name="strClube" id="strClube">
<input type="text" name="strUsuario" id="strUsuario">
<input type="text" name="userKey" id="userKey">
<input type="text" name="clientKey" id="clientKey">
<input type="text" name="datRegister" id="datRegister">
<input type="text" name="arrayGrupos" id="arrayGrupos">
<input type="text" name="arrayUsers" id="arrayUsers">
<input type="text" name="accesLevel" id="accesLevel">
<input type="text" name="strTitulo" id="strTitulo">
<input type="text" name="strDescricao" id="strDescricao">
<input type="text" name="strPathFoto" id="strPathFoto">
</div>
<div class="fileUpload">
<input id="file1" onchange="angular.element(this).scope().getNameFile()" name="file1[]" type="file" multiple size="50" ng-click="selecionouArquivo()"/>
<h2 id="file-name"></h2>
</div>
</form>
-------------------------------------------------------------------
function send in controllers.js
$scope.sendForm = function () {
var form = document.forms.namedItem("form1");
oData = new FormData(form);
var oReq = new XMLHttpRequest();
oReq.open("POST", form.getAttribute('action'), true);
try {
oReq.onload = function (oEvent) {
if (oReq.readyState === 4 && oReq.status == 200) {
var j = JSON.parse(oReq.responseText);
var listaArquivos = j.split('@');
for (var i = 0; i < listaArquivos.length; i++) {
var tmpListaRespostas = listaArquivos[i].split('#');
switch (tmpListaRespostas[1]) {
case 'FILE_UPLOAD_TRUE':
navigator.notification.alert('Arquivo enviado com sucesso!', null, 'Sucesso', 'Fechar');
// alert('Arquivo enviado com sucesso!');
$ionicLoading.hide();
break;
case 'FILE_UPLOAD_EXIST':
navigator.notification.alert('Esse arquivo já existe!', null, 'Alerta', 'Fechar');
// alert('Esse arquivo já existe!');
$ionicLoading.hide();
break;
case 'FILE_UPLOAD_FALSE':
navigator.notification.alert('Ocorreu um erro ao enviar o arquivo!', null, 'Erro', 'Fechar');
// alert('Ocorreu um erro ao enviar o arquivo!');
$ionicLoading.hide();
break;
default:
navigator.notification.alert('Ocorreu um erro desconhecido ao enviar o arquivo!', null, 'Erro', 'Fechar');
// alert('Ocorreu um erro desconhecido ao enviar o arquivo!');
$ionicLoading.hide();
};
};
};
};
/*******************/
/* UPLOAD PROGRESS */
/*******************/
oReq.upload.addEventListener("progress", function (evt) {
if (evt.lengthComputable) {
var percentComplete = (evt.loaded / evt.total) * 100;
$ionicLoading.show({
template: "Enviando:" + Math.floor(percentComplete) + "%"
});
if (Math.floor(percentComplete) == 100) {
$ionicLoading.show({
template: "Enviando...<br />Aguarde..."
});
};
};
}, false);
oReq.send(oData);
} catch (e) {
$ionicLoading.hide();
};
};