Im trying to upload a file to wamp server and is_upload_file returns false for for files over 10mb. Everything work fine for smaller files.
HTML
<button type = "button" id = "uploadbutton">Click</button>
<form id = "fileupload">
<input type="file" name = "uploadfile" id = "uploadfile" style="position: fixed; top: -100em; display:none">
</form>
js
var uploadbutton = document.getElementById("uploadbutton");
var uploadFileInput = document.getElementById("uploadfile");
uploadbutton.onclick = function()
{
uploadFileInput.click();
};
uploadFileInput.onchange = function()
{
onSubmitFile();
};
function onSubmitFile()
{
console.log("onsubmitform");
var fd = new FormData(document.getElementById("fileupload"))
$.ajax({
url: "uploadfile.php",
type: "POST",
data: fd,
enctype: 'multipart/form-data',
processData: false,
contentType: false
}).done(function( data ) {
alert(data);
});
}
PHP
if (is_uploaded_file($_FILES["uploadfile"]["tmp_name"]))
{
$name = $_FILES["uploadfile"]["name"];
move_uploaded_file($_FILES["uploadfile"]["tmp_name"], "C:\\$name");
echo $_FILES["uploadfile"]["name"];
echo "File uploaded";
}
else
{
echo "File not uploaded";
}
print_r($_FILES);
print_r($_FILES)
prints an empty array when is_uploaded_file
fails.
in php.ini
upload_max_filesize 64M post_max_size 20M max_input_time 300 max_execution_time 300
display : none
may trouble you in mobile devices. If you want to hide it then set width and height to0px
– Rayonis_uploaded_file — Tells whether the file was uploaded via HTTP POST
– RayonIT DOES NOT WORK
, but in this case, it does not work only if file is large. – Rayonphpinfo()
– Rayon