>  You are right Dan ;-)
> 
>  The 'Other way' desn't really handle te size. I'm sorry for 
> that. What I was  really thinking is that you can have a 
> control of what amount of data is  being uploaded just 
> counting the loops (1 Kb for every loop).

Oh yeah good idea, what I'd do is thew while loop into a variable.
If the variable is bigger than I like I stopt thew while loop and not write the file.
Otherwise write the variable to the file in 1K chunks if you want or all at once.

That way you don't end up with partial files.

Yeah good idea, check the file size yourself before writing and doing the while on a 
humungousw file!

Thanks for the idea!
Dan

>  -rm-
>  ----- Original Message -----
>  From: "Dan Muey" <[EMAIL PROTECTED]>
>  To: "Ramon Chavez" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
>  Sent: Tuesday, July 08, 2003 2:14 PM
>  Subject: RE: Better way to upload??
> 
> 
>  > Hi all.
> 
>  Howdy
> 
>  >
>  > I need some advice on this.
>  >
>  > I'm writing a script for uploading a file ($file). Saving 
> it  > as $file_path/$name  >  > The way I'm doing this right 
> now is (after checking the file  > extensión and assuring 
> every character is only a letter or an  > underscore):  >  > 
> -My way----------------------------------------
>  > open(LOCAL, ">$file_path/$name") or die $!;
>  >    while(<$file>) {
>  >       print LOCAL $_;
>  >    }
>  > --------------------------------------------------
>  >
>  >
>  > But I have found this other way to do it:
>  > -Other way--------------------------------------
>  > open (LOCAL,">$file_path/$name") or die $!;
>  >   while ($bytesread=read($file,$buffer,1024)) {
>  >       print LOCAL $buffer;
>  >   }
>  > -------------------------------------------------
>  >
>  > The 'Other way' helps to handle the size of the file been
>  > uploaded, but I'm using CGI.pm for doing that, resticting 
> the size.\
> 
>  Th "Other way" doesn't handle the size of the file being 
> uploaded it helps  write it in smaller chunks.  CGI.pm will 
> let you restrict the file to a certain size but the "Other 
> way"  writes  To the new file in smaller chunks no matter if 
> the uploaded file is 1K or  1Mb.
> 
>  Now that we have that all sorted not sure exactly what the 
> pros and cons of  each are as I don't do to much file 
> uploading. But the small amount I do is  pretty much your 
> "Other way" method.
> 
>  HTH
> 
>  DMuey
> 
>  >
>  > I really don't know wich of them both is better. Or what 
> are  > the main advantages (or disadvantages) for each one. I 
> have  > tried my script with many files (Images in my case) 
> and I  > have set some security controls to prevent uploading 
> other  > than images files, but really can't figure where 
> could the  > main advantege be in these two pieces of code.  
> >  > Can you all folks give me some comments on this??.  >  > 
> Maybe I'm losing something and there's an even better way to 
> do it.  >  > Your help is very appreciated  > -rm-  >  >  > 
> --  > To unsubscribe, e-mail: [EMAIL PROTECTED]  
> > For additional commands, e-mail: [EMAIL PROTECTED]  >  >
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to