# PHP - Unable to upload files over 2GB



## ishtar (Aug 24, 2018)

Hello,

I'm seeing a strange issue. When uploading a file through PHP, it always gets truncated to 2GB. The exact error is:

```
PHP Warning:  file_get_contents(): content truncated from 3145728000 to 2147483647 bytes in test.php on line 1
```

I can re-create the error with a 1 line script and accessing it with a browser:

```
<?php echo file_get_contents("3GB.file"); ?>
```

What I've tried:
- Save to NFS instead of ZFS
- Rebuild all PHP and Apache ports

Versions:
- PHP 5.6
- Apache 2.4
- 11.1-RELEASE-p10 AMD64

PHP settings:

```
#  php -i | egrep -i 'memory_limit|max_execution_time|post_max_size|upload_max_filesize|max_input_time'
max_execution_time => 0 => 0
max_input_time => -1 => -1
memory_limit => 16384M => 16384M
post_max_size => 0 => 0
upload_max_filesize => 0 => 0
```

I'm not sure what to try anymore. Does anyone have any insight?

Thanks

EDIT: I've created a VM, installed php 56, and the exact same issue is present. I've removed php56, preserved the same php.ini and installed php72, problem is done. Is this a bug with php 56?


----------



## anlashok (Aug 24, 2018)

This might be a limitation with the browser you are using to upload the file. It would appear that some have 2G limits for POSTing uploads.


----------



## SirDice (Aug 27, 2018)

Configure post_max_size and upload_max_filesize correctly in php.ini (the default of upload_max_filesize is set to 2GB).


----------

