[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROG] [PHP] lidt filhåndtering



On Thu, 22 Aug 2002, tdn wrote:

> function make_dummy_file($filename,$size,$data)
> {
>         if($size > filesize($filename))
>         {
>                 $fp = fopen($filename, "a+");
>                 while(filesize($filename) < $size)
>                 {
>                         fputs($fp, $data);
>                 }
>                 fclose($fp);
>         }
> }
> 
> Men problemet er at den barekommer til at køre i en (tilsyneladende)
> uendelig løkke.

Filen er åben. Jeg kan ikke se anden årsag.

Men den skal jo være $size stor når den er færdig.
Og så er den filesize($filename) stor til at begynde med.
Så mangler der:
  $size = $size - filesize($filename);
data i den fil.

eller
  $size -= filesize($filename);
om du vil.

Hvis du nu prøver:
 $size = $size - filesize($filename);
 # Hvor meget mangler?
 if ($size > 0) {
  $fp = fopen($filename,"a+");
  while ($size > 0) {
   fputs($fp, $data);
   $size -= strlen($data);
  }
  fclose(...

Forstår du hvad der sker?

mvh/hans
-- 
Hamletsgade 4 - 201, DK-2200 København N, Phone: +45 3582 9079
Schou Industries ApS      http://schou.dk/    CVR: 26 13 44 39
--------------------------------------------------------------
Soundcard volume controls for guys who like soundcard volume
controls.		-- http://heroinewarrior.com/mix2000.php3



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 19:58 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *