Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Thread Tools Display Modes
  #1   (View Single Post)  
Old 21st September 2009
cksraj cksraj is offline
Real Name: Crew Kasy Raj
Port Guard
Join Date: Mar 2009
Posts: 12
Default PHP read file contents - Maximum file size

Hi Team

I am trying to read a file contents (CSV file) size of 78MB using PHP. But my code is not working. It is breaking in the below line;

$fcontents = file($import->getCSVName());

But if I read other files which is of size 32MB then it is working fine.

How can I come out of this problem? Is there any limit for file size to read? If so what is the maximum size? Please advice.

Crew Kasy Raj
Reply With Quote
  #2   (View Single Post)  
Old 21st September 2009
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin Tournoij
Tcpdump Spy
Join Date: Apr 2008
Location: Ireland
Posts: 2,245

It's a PHP setting in /usr/local/etc/php.ini
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

; Maximum size of POST data that PHP will accept.
post_max_size = 8M
It's also possible limits are set in login.conf, but the php.ini is more common.

There are two things you can do:
1) Change the php.ini file if you have access to it.
2) Don't read the entire file at once, for example:

$fp = fopen('myfile.csv', 'r');
while ($line = fgets($fp))
  print $line;
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Default Apache won't read .css file erehwon OpenBSD General 23 21st September 2008 10:21 PM
file:/// mfaridi FreeBSD Security 3 27th July 2008 02:18 PM
How to get NAT log file on FreeBSD ? chamnanpol FreeBSD General 1 17th June 2008 11:49 PM
DVD file read error louie FreeBSD General 7 30th May 2008 03:50 PM
Swfdec read-only file access vulnerability corey_james FreeBSD Ports and Packages 0 14th May 2008 11:31 PM

All times are GMT. The time now is 06:21 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick