[Cedarvalley] upload problem

Aaron Thompson thompson at cns.uni.edu
Thu Dec 11 13:52:06 CST 2003


I have been looking and found that I get different data when
using mozilla 1.5 or Netscape 4... it seems like I don't get 
everything...  well... back to reading.

Netscape:

$VAR1 = bless( {
                 '.charset' => 'ISO-8859-1',
                 'upload-me' => [
                                  bless( \*{'Fh::fh00001new_gallery.zip'}, 'Fh' )
                                ],
                 'submit' => [
                               'submit'
                             ],
                 'option' => [
                               'add-galleries'
                             ],
                 'gallery' => [
                                'New_Gallery'
                              ],
                 'function' => [
                                 'upload-gallery'
                               ],
                 '.tmpfiles' => {
                                  '6' => {
                                           'info' => {
                                                       'Content-Disposition' => 'form-data; name="upload-me"; filename="new_gallery.zip"',
                                                       'Content-Type' => 'application/x-zip-compressed'
                                                     },
                                           'name' => bless( do{\(my $o = '/var/tmp/CGItemp443')}, 'TempFile' )
                                         }
                                },
                 '.parameters' => [
                                    'option',
                                    'function',
                                    'gallery',
                                    'upload-me',
                                    'submit'
                                  ],
                 '.fieldnames' => {}
               }, 'CGI' );

Mozilla 1.5:

$VAR1 = bless( {
                 '.charset' => 'ISO-8859-1',
                 'upload-me' => [
                                  'new_gallery.zip'
                                ],
                 'submit' => [
                               'submit'
                             ],
                 'option' => [
                               'add-galleries'
                             ],
                 'gallery' => [
                                'New_Gallery'
                              ],
                 'function' => [
                                 'upload-gallery'
                               ],
                 '.parameters' => [
                                    'option',
                                    'function',
                                    'gallery',
                                    'upload-me',
                                    'submit'
                                  ],
                 '.fieldnames' => {}
               }, 'CGI' );


On Thu, Dec 11, 2003 at 10:54:13AM -0600, Aaron Thompson wrote:
> I'm using CGI to upload a file... the file box is 'upload-me' and the code
> below works for Netscape 4, but not Mozilla 1.5 or IE 6.  Anyone have
> experience with this and can point me in the right direction?
> 
> Error message (from apache error log):
>  Use of uninitialized value in <HANDLE> at /home/httpd/photos/admin/index.cgi line 59.
>  readline() on unopened filehandle at /home/httpd/photos/admin/index.cgi line 59.
> 
> 
> the offending code:
> ---<snip>---
> use CGI;
> ...
> 
> $query = new CGI:
> ...
> 
> ######################################################################
> sub upload_file{
>   my $overwrite = "0"; #overwrite files on upload (yes = 1, no = 0)
>   my %valid_mime = ("zip" => "1");
>   my $length = 0;
>   my $file = $query->param("upload-me");
>   my $local_file_name = "";
>   my $uploadFH; 
>   my $mime;
>   my $save_flag;
> 
>   $file =~ s/.*[\/\\](.*)/$1/;
>   if($file =~ /.*[\.](.*)/){$mime = $1;}#fi
>   $local_file_name = $tmp_dir . "/" .$file;
>   print "<p>File Upload...<br>This may take some time, please wait...</p>";
>   print "<p>Attempting to upload: $file</p>";
>   if ($valid_mime{$mime}){
>     $save_flag = 1;
>     if(! $overwrite){if( -e $local_file_name ){$save_flag = 0;}}#fi
>     if($save_flag){
>       $uploadFH = $query->upload("upload-me");
>       open UPLOADFILE, ">$local_file_name" or
>         html_die("Could not open $local_file_name for writing!");
>         binmode UPLOADFILE;
>         while ( <$uploadFH> ){
>           print UPLOADFILE;
>           $length += length($_);
>         }#elihw
>       close UPLOADFILE;
>       print "<p><b>$file</b> of size <b>$length bytes</b> was uploaded.</p>";
>     }else{
>       print "<p><b>$file</b> already exists on the server - not uploaded. </p>";
>     }#fi
>   }
>   else{
>     print "<p>File not saved... unallowed file time: $mime</p>";
>   }#fi
> }
> 
> ---<snip>---
> 
> Thanks for your help.
> 
> @
> 
> 
> -- 
> Aaron Thompson   Unix Systems Administrator, College of Natural Science
> University of Northern Iowa                      Cedar Falls, IA  50614
> 
> "Because as we know, there are known knowns, there are things we know we
> know. We also know there are known unknowns; that is to say we know there are
> some things we do not know. But there are also unknown unknowns - the ones we
> don't know we don't know." - Donald Rumsfeld
> _______________________________________________
> Cedarvalley mailing list
> Cedarvalley at mail.pm.org
> http://mail.pm.org/mailman/listinfo/cedarvalley

-- 
Aaron Thompson   Unix Systems Administrator, College of Natural Science
University of Northern Iowa                      Cedar Falls, IA  50614

"The ships hung in the sky in much the same way that bricks don't."
                                                        -Douglas Adams



More information about the Cedarvalley mailing list