Jump to content

PHP file size limits


btherl

Recommended Posts

I'm looking for a summary of php's issues with file sizes, but have been unable to find anything useful in google.

 

From what I can tell from experimenting, the 32 bit php (version 4.3.10) cannot handle any file larger than 2GB, but the 64 bit php is ok.  Is there anything I should know?  Is a later version of 32 bit php able to handle large files?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/140782-php-file-size-limits/
Share on other sites

It's very likely, as I'm sure you've figured, happening because PHP's hitting the limit of a signed 32 bit integer. What do you mean by "it can't handle files larger than 2 GB". Do you mean for any specific functions, or do you mean for something crazy such as a PHP script large enough to be over 2 GB in size?

Link to comment
https://forums.phpfreaks.com/topic/140782-php-file-size-limits/#findComment-736857
Share on other sites

When I tested it on the 32 bit php 4.3.10, it stopped writing at 2^31 - 1 bytes and crashed.  So it's not about 2 gb php script :)  I hope no-one has written one of those..
More likely to be an operating system/filesystem limitation than a PHP limitation.

 

e.g. Under ext3, If you are using a 1k filesystem, then a file can consist of ten

direct blocks, plus 256 data blocks addressed via the indirect block,

plus 256*256 data blocks addressed from the indirect block, plus

256*256*256 data blocks from the triple-indirect block:

 

(10 + 256 + 256*256 + 256*256*256) * 1024 = 17247252480

 

However, take a look at this thread which discusses a 2GB file limit on 32-bit processors

Link to comment
https://forums.phpfreaks.com/topic/140782-php-file-size-limits/#findComment-736933
Share on other sites

Thanks for that link.

 

The problem is with php unfortunately, not the filesystem.  We use the same filesystems here with 64 bit php and it deals with files over 2GB without trouble.  It's just this particular job had to run on an older 32 bit machine (using the same fs via nfs).  In the end we resolved it by making the necessary changes to have the job run on a 64 bit machine.

 

aschk, we have both 32 bit and 64 bit OS here, and use 32 bit php on the 32 bit ones and 64 bit php on the 64 bit ones :)  I'm not sure if you can make a 32 bit php on the 64 bit OS.  But you definitely can't make the 64 bit on on a 32 bit OS.

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/140782-php-file-size-limits/#findComment-737374
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.