This part:
while ($bytesread=read($file,$buffer,1024))Has the effect of repeatedly bringing 1Kbyte of data into $buffer from $file. The value returned by the read() is the number of bytes read, so once the filehandle is exhausted the while loop stops. In effect it just sucks the uploaded data through $buffer 1K at a time until it has traversed the whole filehandle.
I agree that it's a slightly odd way round, compared to eg splice: i expect that's in order to allow exactly this construction.
For more, see read or man CGI (from which this code mostly comes).
In reply to Re: Re: saving a file uploaded with cgi...this is driving me insane.
by thpfft
in thread saving a file uploaded with cgi...this is driving me insane.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |