|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-08-10 06:17 UTC] richard at zend dot com
<HTML><BODY>
<?php
set_time_limit(0);
clearstatcache();
$input = fopen('C:/phpcvs/phpcvs.tar.gz', 'r') or die('could not open input');
$output = fopen('A:/phpcvs.tar.gz.1', 'w') or die('could not open ouput');
$start = 0;
$chunk = 100;
$length = 1024*1024;
fseek($input, $start);
$current = $start;
echo "Filesize is ", filesize('C:/phpcvs/phpcvs.tar.gz'), "<BR>\n";
while ($current < $length && !feof($input)){
$data = fread($input, $chunk);
$wrote = fwrite($output, $data, $chunk);
$current += $wrote;
echo $current, "<BR>\n";
flush();
}
$count = 330;
(fseek($input, 330)+1) or die ("Error fseeking 330<BR>\n");
while (!feof($input) && $count < 350){
$char = fgetc($input);
echo ftell($input), " '$char' (", ord($char), ")<BR>\n";
$count++;
}
fclose($input);
fclose($output);
echo "<BR>Done.";
?>
</BODY></HTML>
OUTPUT:
Filesize is 2233724
100
200
300
337
331 '' (0)
332 'S' (83)
333 ';' (59)
334 'N' (78)
335 ';' (59)
336 '?' (245)
337 '|' (124)
338 '?' (137)
842 '?' (200)
4427 '' (16)
4428 'x' (120)
4429 'F' (70)
4430 '^' (94)
4431 'e' (101)
4432 '?' (154)
4433 '?' (235)
4434 '?' (239)
4435 '' (15)
4436 '7' (55)
4437 'b' (98)
Done.
Expected Output:
1.4 Megs copied 100 bytes at a time, and something sensible from ftell after byte 338...
filesize() knows how big the file is, but fread, feof, fgetc, etc are all convinced it's only 337 bytes long...
But char 337 and 338 are not even end of string. 331 is, but it's not even dying there, which would almost make sense, except fread and fgetc are supposed to be binary safe...
The mod_php4.dll from that geocities guy is in there... Relevant? One wouldn't think so...
The php.exe seems to work just fine, so I guess it is though, unless it's in some other DLL that gets involved with Apache and PHP somehow, but not with PHP.exe.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 01:00:02 2025 UTC |
Feedback: "Seems to work okay... But I don't have the exact same file to test on. :-(" Please reopen if this problem resurfaces later. --Jani