|
|
|
|
![]() ![]() |
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. |
|
|
|
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?
|
|
|
|
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 |
|
|
|
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); ?> |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 7th October 2008 - 09:05 AM |