DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

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

Reply
 
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
Thanked 0 Times in 0 Posts
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.

Thanks,
Crew Kasy Raj
Reply With Quote
  #2   (View Single Post)  
Old 21st September 2009
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,068
Thanked 198 Times in 156 Posts
Default

It's a PHP setting in /usr/local/etc/php.ini
Code:
; 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:

Code:
$fp = fopen('myfile.csv', 'r');
while ($line = fgets($fp))
{
  print $line;
}
fclose($fp)
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
Reply

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 12:25 PM.


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