You are here: Re: [PHP] fopen « PHP « IT news, forums, messages
Re: [PHP] fopen

Posted by Jochem Maas on 10/26/05 10:27

John Taylor-Johnston wrote:
> It does what I want, but I worry 4096 may not be big enough. Possible?

4096 is the number of bytes fgets() will get, but the fgets()
call is inside a while loop which keeps running until the 'filepointer'
(as denoted by the handle $dataFile) in question has reached the end of the
given file. so if 4096 is not big enough the loop merely grabs another 4096
bytes until its grabbed it all.

so actually you have a handy bit of code which will allow you to 'eat' through
massive files without the requirement of being able to store the
whole file in memory.

> Is there a way to detect the filesize and insert a value for 4096?

filesize()

> $buffer = fgets($dataFile, $filesize);
> Is this what it is for?
> John
>
>
> <?php
> #http://ca3.php.net/fopen
> $filename = "/var/www/html2/assets/about.htm" ;
> $dataFile = fopen( $filename, "r" ) ;
> while (!feof($dataFile))
> {
> $buffer = fgets($dataFile, 4096);
> echo $buffer;
> }
> $sql = "insert into table ... $buffer";
> ?>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация