Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> How To Read Large Files In Php., Tutorial on reading large files in PHP.
renegade_divisio...
post Oct 4 2005, 05:30 PM
Post #1


Newbie
*

Group: Members
Posts: 1
Joined: 4-October 05
Member No.: 12,541



First of all don't use file() function instead use fread() functions.
I think you should deploy the split-script technique. Its different
from splitting your text file. Instead you get two scripts to do the
same job.
Or you can deploy the following method.
First of all you should be knowing the size of the max text file which
can be read in the max_execution_time on your Web Server.
For that you need to use fread() function. with something like this:
CODE

$file=fopen("file.txt","r");
$count=0;
while(!feof($file))
{
$data=fread($file,1024);
print($count+"<br>");
flush();//flush it in between
ob_flush();//so that you get the count of max number of 1024 chunks
supported
$count++;
}

Now when the script crashes note down the count number and copy the
script where you used the file() function with some other name.
For example:
CODE

//file_proc.php
if(!isset($_GET['startcount'])&&!isset($_GET['startcount']))
{
$startcount=0;
$endcount=$max_count_supported;//the number you took from the last
script.
}
$file=fopen("file.txt","r");
fseek($file,($endcount-$startcount)*1024);
for($count=0;$count<=($endcount-$startcount);$count++)
{
$data=fread($file,1024);
//Process the data here
}
//Redirect the script to  file_proc.php?startcount=$endcount&endcount=($endcount+$max_supported_count)

I guess this should be getting the work done.
Go to the top of the page
 
+Quote Post
snlildude87
post Oct 4 2005, 09:08 PM
Post #2


Moderator
***************

Group: Members
Posts: 2,325
Joined: 8-March 05
From: Mawson, Antarctica
Member No.: 4,254



Hmm, do you know the average maximum file size that can be read on a server?
Go to the top of the page
 
+Quote Post
mendezgarcia
post Oct 5 2005, 12:07 AM
Post #3


Newbie [Level 3]
***

Group: Members
Posts: 46
Joined: 11-September 05
Member No.: 11,743



snlildude87: the problem is not the max file size, it's the max execution time, which is usually set to 30.

renegade_division: you can, instead of doing this, increase the max_execution_time value (PHP_INI_ALL), using for example ini_set().

http://www.php.net/ini_set
http://www.php.net/manual/en/ini.php#ini.list
Go to the top of the page
 
+Quote Post
snlildude87
post Oct 5 2005, 12:31 AM
Post #4


Moderator
***************

Group: Members
Posts: 2,325
Joined: 8-March 05
From: Mawson, Antarctica
Member No.: 4,254



mendez, so will I have to do something like this:

CODE
<?php
 ini_set("max_execution_time", 99);
?>
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Css And Javascript Combined For Dynamic Layout(9)
  2. How To Read And Write Files Using Php(20)
  3. Delete Files And Directories Using Php(7)
  4. Building An Unordered List Of Anchors(4)
  5. Templating System Using Php Includes(13)
  6. Php Script To Make A Link List(6)
  7. How To Open Bam & Tt Files, long 3 part tutorial(2)
  8. How To Create Self-unzipping Files(18)
  9. How To Chmod Files(16)
  10. How To Fix Problems With Shareaza(1)
  11. Cpanel Analysis And Log Files(0)
  12. How To Better Compress Files In Winrar(7)
  13. How To Hide Your Important Files And Folders(7)
  14. Download Files Off Esnips.com(0)
  15. Debug Exe Files(4)
  1. How To Download Any Flv Files From Any Sites(6)
  2. Clearing Your Ie Tif(0)
  3. How To Create Pdf Files Using Free Tool(0)
  4. Deny Or Grant Users Access To Files Of Choice (vista)(3)


 



- Lo-Fi Version Time is now: 7th October 2008 - 09:05 AM