0

I'm trying to upload a file with the size of e.g. 244 KB via POST request with PHP but it causes a 403 Forbidden error. When I upload a small file (e.g. 3 B) it works fine.

I've made sure my PHP.ini is configured to support bigger files as seen below in the CPanel screenshot:

My PHP script is the following:

<?php

$filename = $_GET['filename'];
$fileData = file_get_contents('php://input');
file_put_contents($filename, $fileData);

Error handling and such removed for clarity.

Adding a user agent to the POST request does not help.

What could be the cause of bigger files being refused to be uploaded?

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
  • 2
    after saving the changes in your php.ini file have you restarted your server?cause if not you need to do that. – Kunal Raut May 23 '20 at 17:05
  • 2
    you can reload the config changes by `service apache reload`. – Mohammad Imran May 23 '20 at 17:14
  • `CPanel` already reloaded the server after changing the config. This isn't the problem, the file size wasn't that low to begin with. – BullyWiiPlaza May 23 '20 at 17:56
  • Do you have Apache mod_security Module Enabled? And Have you verified the Configuations are updated in your project with `phpinfo()` ? – Harish ST May 23 '20 at 18:09
  • @HarishST: The `phpinfo()` page says `PHP Version 7.4.6` and `$_SERVER['SERVER_SOFTWARE'] = Apache` but it does not mention `mod_security` – BullyWiiPlaza May 23 '20 at 19:14
  • Try this one: https://stackoverflow.com/questions/17076893/apache-403-forbidden-when-uploading-files – Harish ST May 23 '20 at 19:44

0 Answers0