I have an image upload script that works normally with Chrome, EDGE, Firefox and Opera. But it does not work with Safari. The Safari browser opens the windows window for me to choose an image. When it should upload, it sends the data of the chosen image as NULL (empty). I have read several topics and articles, but none of them solved my problem.
Can anyone help me understand where the error is?
In PHP you have the following:
<form id="formImg" style="cursor: pointer;" enctype='multipart/form-data' method="post">
<input type="file" id="fileUpload" name="fileUpload[]" onchange="saveImg()" onClick="" accept='image/*' >
</form>
I have already tried using the TAG form the following action:"javascript:;" accept-charset="utf-8";
I read in an article. But nothing changes.
js has the following:
function saveImg()
{
$('#formImg').ajaxSubmit({
url : 'upload.php',
type : 'POST',
// async: false,
cache: false,
contentType: false,
processData: false,
headers: { 'cache-control':'no-cache' },
success: function (response) {
if (response === "OK") {
location.reload();
} else {
alert (response);
}
}
});
I've used with and without the cache, contentType, and so on attributes. Nothing worked. I also put in the head of the html the following:
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
I read in other articles that this cache problem could interfere. But that has not changed either. Neither with nor without. Still not working in Safari.
Finally, in php that processes the data (upload.php), I put a small code that allows me to always know if it is sending the data as NULL,
if($_FILES['fileUpload']==NULL){
echo "Vazio";
exit;}
and in all attempts, it always returns "Empty". Already in other browsers, it works normally.
Can anyone help? I do not know what to change in this code to work in Safari. Thanks!