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
Share on other sites

The operation in question is fopen() followed by fwrite().  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..

Link to comment
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.