Question on files

This is a discussion on "Question on files" within the PHP Forum section. This forum, and the thread "Question on files are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 1st, 2006, 23:03
Up'n'Coming Member
Join Date: Sep 2005
Location: athens
Age: 25
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Question on files

Hi,
I am using PHP to make a website related to biology. In this site I use PHP code to communicate with external programms (not in PHP, but some biological packages). These programms write their output in temporary files, which I then read using fread() or file_get_contents() functions.
My problem is that these functions seem to have a restriction as to the size of the file that they can read. Is there any other way I read big files (for files close to 20-30MBs for example)?
Please note that there is no other way for me to do this because these programs, by default, write their output to a text file, so I can't use PHP's system commands and read the output on the fly. The output file is first created and then I read it into a string and parse it according to what I need.
Reply With Quote

  #2 (permalink)  
Old May 4th, 2006, 03:27
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Question on files

I've handled files up to 2 GBytes in size with PHP ... but there are a number of issues to consider.

1. The size of the PHP "footprint" in memory - when you have a huge data file, you cannot simply read it all in with file or file_get_contents (nor with fread, trying to read the file all at once). Rather, you need to iterate through the file in blocks - typically a line at a time, but I've also worked in 100k bloacks.

2. You are very likely to hit the fierce time limit that PHP imposes to stop a program that's looping infinitely from hogging the server for too long. You can solve that one by increasing the time limit.

3. Browsers will also time out (and users of your page get bored too) if you're not able to give a response quite quickly. Options to solve this include sending out a holding page / update periodically and (the way I did it) running my PHP analysis of the huge data file as a command line program rather than through the browser.

-- Graham
Reply With Quote
  #3 (permalink)  
Old May 7th, 2006, 14:47
New Member
Join Date: May 2006
Age: 16
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Question on files

Quote:
Originally Posted by ktsirig
Hi,
I am using PHP to make a website related to biology. In this site I use PHP code to communicate with external programms (not in PHP, but some biological packages). These programms write their output in temporary files, which I then read using fread() or file_get_contents() functions.
My problem is that these functions seem to have a restriction as to the size of the file that they can read. Is there any other way I read big files (for files close to 20-30MBs for example)?
Please note that there is no other way for me to do this because these programs, by default, write their output to a text file, so I can't use PHP's system commands and read the output on the fly. The output file is first created and then I read it into a string and parse it according to what I need.
Would the include() function work better in this case? If your trying to insert it, wouldn't that be better.
Reply With Quote
  #4 (permalink)  
Old May 8th, 2006, 23:04
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 25
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Tim356
Re: Question on files

I think he's manipulating the data within those text files, not just including them on his page.
Reply With Quote
Reply

Tags
question, files

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
upload files monstermunch Starting Out 6 May 4th, 2007 18:27
.jar files AdjLaz JavaScript Forum 1 Jul 27th, 2006 13:57
files not uploading skyfire400 Hosting & Domains 1 Mar 4th, 2006 18:30
Help with MP3 Files ricky1911 Web Page Design 5 Dec 13th, 2005 23:13
".lbi" files MotorMouth PHP Forum 2 Oct 18th, 2004 05:20


All times are GMT. The time now is 05:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43