skelto skelto - 1 year ago 62
Ajax Question

File too large to upload to server even when php.ini file altered

I have been unable to upload a (.OBJ) file to the server and get an 'Error 1' meaning that

The uploaded file exceeds the upload_max_filesize directive in php.ini

I got this information from this page -

I then went to the php.ini file and changed both the
and the
to 10000M.

I still get an 'Error 1' when I try to upload the file even though it is only 3MB. I have also restarted the server so that changes I have made to the php.ini file can come into effect. I know that my code works for smaller files as I have been able to send a small TXT file that contains the word "Test".

Here is the form.php file that contains the PHP code for handling the sent file on the server side and HTML code to create the file selection and upload functionality.

ini_set('display_errors', 1);

ini_set('max_execution_time', 3000000);

echo "<br/><b>File Name:</b> " . $_FILES["file"]["name"] . "<br>";
echo "<b>Type:</b> " . $_FILES["file"]["type"] . "<br>";
echo "<b>Size:</b> " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "<b>Temp File Name:</b> " . $_FILES["file"]["tmp_name"] . "<br>";
echo "<b>Error:</b> " . $_FILES["file"]["error"] . "<br>";

$sourcePath = $_FILES['file']['tmp_name']; // Storing source path of the file in a variable
$targetPath = "upload/" . $_FILES['file']['name']; // Target path where file is to be stored

move_uploaded_file($sourcePath, $targetPath);


<!DOCTYPE html>
<script src=""></script>
<form action="form.php" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" value="Upload">

$(function () {
$('form').on('submit', function (e) {

url: this.action,
type: this.method,
data: new FormData(this),
processData: false,
contentType: false,
success: function (res) {


To sum up my question is, why can I not upload the desired file even though I have changed the appropriate variables of the php.ini file?


You have to restart you Webserver:

service apache restart #If you have Apache
service nginx restart #If you have NGINX

If your running php-fpm:

service php-fpm restart

Do you have multiple php.ini's? Look out for:


Under some circumstances you also have to allow bigger file uploads on your Webserver.


client_max_body_size 10000M;