Rachel Polanskis wrote:

> Please excuse the perl question but Iam at my wits end.
> 
> I have written a CGI file_upload script that works fine with a
> UNIX web browser.

What is the web server running on?



> When I go to use a Gates-based browser like netscape or IE,
> it uploads the file OK, but it's Zero-Length.
> 
> I have done all the path clearing stuff to make sure just the
> correct name of the file is uploaded.
> 
> In my upload code I make sure I do a binmode() on the filehandle
> for the windoze stuff to work properly.

The bimode() call is only if the *server* is running on Windows,
not for the client.  On a *nix server, all file I/O is binary,
so there is no need for the binmode() call. Windoze/DOS distinguishes
between text and binary streams.



> My code snippet looks like
> 
>         open (SAVE, ">/path/to/save_dir/$file");
>         binmode (SAVE);
> 
>         while (read ($file,$data,1024)){
>         print SAVE $data;
>         }
>         close SAVE;
>         chmod (/path/to/save_dir/$file, 0644);
> 
> Now all this works fine when I use a UNIX browser but
> fails to work with a Windoze one.  The file gets uploaded but is
> empty!

Perhaps you should stat the file handle returned by the CGI,
find out the file length and debug dump it.

Also, ensure

1. $file is a CGI variable from a field of the form
   <input type=file name=file>

2. your form's content encoding is "multipart/form-data"
   and not "application/x-www-form-urlencoded"

I mention (2) since perhaps that is difference between the Unix
and the 'Doze browsers. Perhaps if you get it wrong in Unix
(and are using "application/x-www-form-urlencoded") the
browser fixes it up and sends in the multi-part data anyway?!?!

-rick

_____________________________________________
Rick Welykochy || Praxis Services Pty Limited

"My Windows box sits in the corner, an appliance to run legacy software.
 In my opinion, that's the ideal use of Windows."    Steve Litt

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to