I have an uploader
JS Part:
function uploadData(data){
var xhr = new XMLHttpRequest();
var fData = new FormData();
for (var k1 in requestData)
if (requestData.hasOwnProperty(k1))
fData.append(k1, requestData[k1]);
xhr.open("POST", "ajax/upload", true);
xhr.send(fData);
}
And PHP part:
$fileContent = file_get_contents($_FILES['file']['tmp_name']);
file_put_contents(FILES_PATH."/".$_POST['name'], $fileContent);
I also have a form on html. After click upload button:
var file = document.getElementById('files').files[0];
var ext = file.name.split(".").pop();
var name = getRandomString(5) + "." + ext;
uploadData({"file": file, "name": name});
It works with all files (I tested png, jpg, pdf, doc... mp3) but it doesn't work with .DMG extension. I tested everything. In xhr i used a console and i saw that file exists. When i tried to see $_POST
, $_REQUEST
or $_FILES
content i didn't see my .dmg file..