feof() problem

This is a discussion on feof() problem within the PHP General forums, part of the PHP Programming Forums category; Hi My Code : <?php $uploaddir = '/tmp'; print "<pre>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-22-2003
Chandrakant Reddy
 
Posts: n/a
Default feof() problem


Hi
My Code :

<?php
$uploaddir = '/tmp';
print "<pre>";

if
(move_uploaded_file($_FILES['userfile']['tmp_name'],
$uploaddir . $_FILES['userfile']['name'])) {

print "File is valid, and was successfully
uploaded. Here's some more debugging info:\n";
print_r($_FILES);
$filename = $uploaddir .
$FILES['userfile']['name'] ;

$filehandle = fopen($filename,"r");

if(! $filehandle) { echo ("<br> file opening
error </br>"); }
else { echo (" file opened in read mode ");
$count=0;
ini_set('auto_detect_line_endings',
true);
while( (!feof($filehandle) ) && $count
< 100 ) {
$line = fgets($filehandle,4096);
#$line =
explode(":",fgets($filehandle,100) ) ;
echo " line = " . $line ;
#print_r($line);
$count++;
if($count > 90 ) echo " some problem
";
echo ("<BR><BR>");
}

fclose($filehandle);

}

} else {
print "Possible file upload attack! Here's some
debugging info:\n";
print_r($_FILES);
} ?>


The output that I am getting :


File is valid, and was successfully uploaded. Here's
some more debugging info:
Array
(
[userfile] => Array
(
[name] => filename.txt
[type] => text/plain
[tmp_name] => /tmp/phpq8YmxN
[error] => 0
[size] => 466
) )
file opened in read mode line =
line =
line =
# 90 lines then it is printing

line = someproblem
# ten lines


My question is why it is going into infite loop ,what
is problem with the above code.


regards
CVR


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Reply With Quote
  #2 (permalink)  
Old 07-22-2003
Jason Wong
 
Posts: n/a
Default Re: [PHP] feof() problem

On Tuesday 22 July 2003 14:44, chandrakant Reddy wrote:

[snip]

> The output that I am getting :
>
>
> File is valid, and was successfully uploaded. Here's
> some more debugging info:
> Array
> (
> [userfile] => Array
> (
> [name] => filename.txt
> [type] => text/plain
> [tmp_name] => /tmp/phpq8YmxN
> [error] => 0
> [size] => 466
> ) )
> file opened in read mode line =
> line =
> line =
> # 90 lines then it is printing
>
> line = someproblem
> # ten lines
>
>
> My question is why it is going into infite loop ,what
> is problem with the above code.


Could you explain what you mean by infi[ni]te loop? How is it manifesting
itself? Is it printing the above non-stop?

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
It is much harder to find a job than to keep one.
*/

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:57 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0