From thompson at cns.uni.edu Wed Dec 10 17:26:56 2003 From: thompson at cns.uni.edu (Aaron Thompson) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] using subs with an s///g? Message-ID: <20031210232656.GP28940@faculty.cns.uni.edu> I would like to replace a string with the results of a sub program the idea is as follows... I have a sub 'display_gallery_list' that returns an HTML table listing some galleries... and I want to replace the string '' with the results of the sub. Also this global replacement is preferred. something like this should be possible: $data =~ s//&display_gallery_list/g; I don't want to use the $` and $' variables... Any ideas/suggestions? @ -- Aaron Thompson Unix Systems Administrator, College of Natural Science University of Northern Iowa Cedar Falls, IA 50614 "My doctor says that I have a malformed public-duty gland and a natural deficiency in moral fiber, and that I am therefore excused from saving Universes." -Douglas Adams From thompson at cns.uni.edu Wed Dec 10 17:47:42 2003 From: thompson at cns.uni.edu (Aaron Thompson) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] using subs with an s///g? In-Reply-To: <20031210232656.GP28940@faculty.cns.uni.edu> References: <20031210232656.GP28940@faculty.cns.uni.edu> Message-ID: <20031210234742.GR28940@faculty.cns.uni.edu> Now to answer my own question... the fix: $data =~ s//display_gallery_list()/eg; ... anyone know what the 'e' does (other than what I want)? @ On Wed, Dec 10, 2003 at 05:26:56PM -0600, Aaron Thompson wrote: > I would like to replace a string with the results of a sub > program the idea is as follows... > > I have a sub 'display_gallery_list' that returns an HTML table > listing some galleries... and I want to replace the string > '' with the results of the sub. > Also this global replacement is preferred. > > something like this should be possible: > > $data =~ s//&display_gallery_list/g; > > I don't want to use the $` and $' variables... > > Any ideas/suggestions? > > @ > > -- > Aaron Thompson Unix Systems Administrator, College of Natural Science > University of Northern Iowa Cedar Falls, IA 50614 > > "My doctor says that I have a malformed public-duty gland and a natural > deficiency in moral fiber, and that I am therefore excused from saving > Universes." -Douglas Adams > _______________________________________________ > Cedarvalley mailing list > Cedarvalley@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 "Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so." -Douglas Adams From thompson at math-cs.cns.uni.edu Thu Dec 11 10:54:13 2003 From: thompson at math-cs.cns.uni.edu (Aaron Thompson) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] upload problem Message-ID: <20031211165413.GW28940@faculty.cns.uni.edu> 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 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: ------ 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 "

File Upload...
This may take some time, please wait...

"; print "

Attempting to upload: $file

"; 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 "

$file of size $length bytes was uploaded.

"; }else{ print "

$file already exists on the server - not uploaded.

"; }#fi } else{ print "

File not saved... unallowed file time: $mime

"; }#fi } ------ 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 From thompson at cns.uni.edu Thu Dec 11 13:52:06 2003 From: thompson at cns.uni.edu (Aaron Thompson) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] upload problem In-Reply-To: <20031211165413.GW28940@faculty.cns.uni.edu> References: <20031211165413.GW28940@faculty.cns.uni.edu> Message-ID: <20031211195206.GB28940@faculty.cns.uni.edu> 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 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: > ------ > 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 "

File Upload...
This may take some time, please wait...

"; > print "

Attempting to upload: $file

"; > 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 "

$file of size $length bytes was uploaded.

"; > }else{ > print "

$file already exists on the server - not uploaded.

"; > }#fi > } > else{ > print "

File not saved... unallowed file time: $mime

"; > }#fi > } > > ------ > > 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@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 From wells at cedarnet.org Wed Dec 17 11:10:27 2003 From: wells at cedarnet.org (Stephen D. Wells) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] upload problem In-Reply-To: <20031211195206.GB28940@faculty.cns.uni.edu> References: <20031211165413.GW28940@faculty.cns.uni.edu> <20031211195206.GB28940@faculty.cns.uni.edu> Message-ID: <1071681026.21855.83.camel@localhost.localdomain> I'm back home now and can email again... for some reason the web-based mailer I was using wasn't sending out - I'm back to evolution now though and things are back to normal. Is this still an issue? STEVE On Thu, 2003-12-11 at 13:52, Aaron Thompson wrote: > 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 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: > > ------ > > 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 "

File Upload...
This may take some time, please wait...

"; > > print "

Attempting to upload: $file

"; > > 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 "

$file of size $length bytes was uploaded.

"; > > }else{ > > print "

$file already exists on the server - not uploaded.

"; > > }#fi > > } > > else{ > > print "

File not saved... unallowed file time: $mime

"; > > }#fi > > } > > > > ------ > > > > 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@mail.pm.org > > http://mail.pm.org/mailman/listinfo/cedarvalley -- Stephen D. Wells From thompson at cns.uni.edu Wed Dec 17 11:15:35 2003 From: thompson at cns.uni.edu (Aaron Thompson) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] upload problem In-Reply-To: <1071681026.21855.83.camel@localhost.localdomain> References: <20031211165413.GW28940@faculty.cns.uni.edu> <20031211195206.GB28940@faculty.cns.uni.edu> <1071681026.21855.83.camel@localhost.localdomain> Message-ID: <20031217171535.GA10878@faculty.cns.uni.edu> oh yes... I'm not quite sure what I'm doing wrong. @ On Wed, Dec 17, 2003 at 11:10:27AM -0600, Stephen D. Wells wrote: > I'm back home now and can email again... for some reason the web-based > mailer I was using wasn't sending out - I'm back to evolution now though > and things are back to normal. Is this still an issue? > > STEVE > > On Thu, 2003-12-11 at 13:52, Aaron Thompson wrote: > > 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 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: > > > ------ > > > 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 "

File Upload...
This may take some time, please wait...

"; > > > print "

Attempting to upload: $file

"; > > > 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 "

$file of size $length bytes was uploaded.

"; > > > }else{ > > > print "

$file already exists on the server - not uploaded.

"; > > > }#fi > > > } > > > else{ > > > print "

File not saved... unallowed file time: $mime

"; > > > }#fi > > > } > > > > > > ------ > > > > > > 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@mail.pm.org > > > http://mail.pm.org/mailman/listinfo/cedarvalley > -- > Stephen D. Wells -- 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 From wells at cedarnet.org Wed Dec 17 16:03:52 2003 From: wells at cedarnet.org (Stephen D. Wells) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] using subs with an s///g? In-Reply-To: <20031210234742.GR28940@faculty.cns.uni.edu> References: <20031210232656.GP28940@faculty.cns.uni.edu> <20031210234742.GR28940@faculty.cns.uni.edu> Message-ID: <1071698632.21861.377.camel@localhost.localdomain> 'e' is for execute or eval. The result is run as perl code and the result of that code is replaced with the match. example: Uppercase the first letter of every word... $string =~ s/(\b\w)/uc($1)/eg; on a side note... you might want to be able to include attributes to in your data and/or dynamically process subroutines... In that case see if something like this looks interesting... complete example ---------------- #!/usr/bin/perl -w use strict; while () { no strict 'refs'; s//&$1($4)/gex; print; } sub food { my @attrib = (); @attrib = split(/,/, $_[0]) if (defined($_[0])); 'called food ('. join("::", @attrib).')'; } __DATA__ hello world how are you today? complete [steve@dev steve]$ perl dat_rep.pl hello world how are you today? called food (corn beef) called food () called food (watermellon::peanut::cabbage) called food (peanut butter) complete --------- You may need to tweak it depending on your needs. STEVE On Wed, 2003-12-10 at 17:47, Aaron Thompson wrote: > Now to answer my own question... > > the fix: > > $data =~ s//display_gallery_list()/eg; > > ... anyone know what the 'e' does (other than what I want)? > > @ > > > On Wed, Dec 10, 2003 at 05:26:56PM -0600, Aaron Thompson wrote: > > I would like to replace a string with the results of a sub > > program the idea is as follows... > > > > I have a sub 'display_gallery_list' that returns an HTML table > > listing some galleries... and I want to replace the string > > '' with the results of the sub. > > Also this global replacement is preferred. > > > > something like this should be possible: > > > > $data =~ s//&display_gallery_list/g; > > > > I don't want to use the $` and $' variables... > > > > Any ideas/suggestions? > > > > @ > > > > -- > > Aaron Thompson Unix Systems Administrator, College of Natural Science > > University of Northern Iowa Cedar Falls, IA 50614 > > > > "My doctor says that I have a malformed public-duty gland and a natural > > deficiency in moral fiber, and that I am therefore excused from saving > > Universes." -Douglas Adams > > _______________________________________________ > > Cedarvalley mailing list > > Cedarvalley@mail.pm.org > > http://mail.pm.org/mailman/listinfo/cedarvalley -- Stephen D. Wells From wells at cedarnet.org Wed Dec 17 16:08:58 2003 From: wells at cedarnet.org (Stephen D. Wells) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] upload problem In-Reply-To: <20031217171535.GA10878@faculty.cns.uni.edu> References: <20031211165413.GW28940@faculty.cns.uni.edu> <20031211195206.GB28940@faculty.cns.uni.edu> <1071681026.21855.83.camel@localhost.localdomain> <20031217171535.GA10878@faculty.cns.uni.edu> Message-ID: <1071698938.21859.382.camel@localhost.localdomain> If I understand you right it works with netscape but not mozilla... Do you have a small complete example (including your html) somewhere? STEVE On Wed, 2003-12-17 at 11:15, Aaron Thompson wrote: > oh yes... I'm not quite sure what I'm doing wrong. > > @ > > On Wed, Dec 17, 2003 at 11:10:27AM -0600, Stephen D. Wells wrote: > > I'm back home now and can email again... for some reason the web-based > > mailer I was using wasn't sending out - I'm back to evolution now though > > and things are back to normal. Is this still an issue? > > > > STEVE > > > > On Thu, 2003-12-11 at 13:52, Aaron Thompson wrote: > > > 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 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: > > > > ------ > > > > 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 "

File Upload...
This may take some time, please wait...

"; > > > > print "

Attempting to upload: $file

"; > > > > 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 "

$file of size $length bytes was uploaded.

"; > > > > }else{ > > > > print "

$file already exists on the server - not uploaded.

"; > > > > }#fi > > > > } > > > > else{ > > > > print "

File not saved... unallowed file time: $mime

"; > > > > }#fi > > > > } > > > > > > > > ------ > > > > > > > > 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@mail.pm.org > > > > http://mail.pm.org/mailman/listinfo/cedarvalley > > -- > > Stephen D. Wells -- Stephen D. Wells From thompson at cns.uni.edu Fri Dec 19 09:42:29 2003 From: thompson at cns.uni.edu (Aaron Thompson) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] upload problem In-Reply-To: <1071698938.21859.382.camel@localhost.localdomain> References: <20031211165413.GW28940@faculty.cns.uni.edu> <20031211195206.GB28940@faculty.cns.uni.edu> <1071681026.21855.83.camel@localhost.localdomain> <20031217171535.GA10878@faculty.cns.uni.edu> <1071698938.21859.382.camel@localhost.localdomain> Message-ID: <20031219154229.GF10878@faculty.cns.uni.edu> The problem seems to be that it doesn't work with Mozilla 1.5 or IE 6 but works fine with NS 4.7 (I don't have a copy of a new NS browser to test with). Here is the code/html: Thanks for your help. ---------- ... sub upload_file{ my $overwrite = "1"; #overwrite files on upload (yes = 1, no = 0) my $length = 0; my $file = $query->param("upload-me"); my $local_file_name = ""; my $uploadFH; my $save_flag; $file =~ s/.*[\/\\](.*)/$1/; $local_file_name = $tmp_dir . "/" .$file; print "

File Upload...
This may take some time, please wait...

"; print "

Attempting to upload: $file

"; $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 "

$file of size $length bytes was uploaded.

"; } else{ print "

$file already exists... could not upload.

"; }#fi } ... ---------- ---------- server.domain
Upload a gallery for aaron
NOTE: The following limitations will apply when using this tool...
  • this will only work with .zip files
  • you should not have any spaces in your image files or zip file.
  • Once you agree to send the data nothing will display untill the transfer is complete.

upload file:
Edit Galleries
---------- On Wed, Dec 17, 2003 at 04:08:58PM -0600, Stephen D. Wells wrote: > If I understand you right it works with netscape but not mozilla... Do > you have a small complete example (including your html) somewhere? > > STEVE > > On Wed, 2003-12-17 at 11:15, Aaron Thompson wrote: > > oh yes... I'm not quite sure what I'm doing wrong. > > > > @ > > > > On Wed, Dec 17, 2003 at 11:10:27AM -0600, Stephen D. Wells wrote: > > > I'm back home now and can email again... for some reason the web-based > > > mailer I was using wasn't sending out - I'm back to evolution now though > > > and things are back to normal. Is this still an issue? > > > > > > STEVE > > > > > > On Thu, 2003-12-11 at 13:52, Aaron Thompson wrote: > > > > 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 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: > > > > > ------ > > > > > 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 "

File Upload...
This may take some time, please wait...

"; > > > > > print "

Attempting to upload: $file

"; > > > > > 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 "

$file of size $length bytes was uploaded.

"; > > > > > }else{ > > > > > print "

$file already exists on the server - not uploaded.

"; > > > > > }#fi > > > > > } > > > > > else{ > > > > > print "

File not saved... unallowed file time: $mime

"; > > > > > }#fi > > > > > } > > > > > > > > > > ------ > > > > > > > > > > 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@mail.pm.org > > > > > http://mail.pm.org/mailman/listinfo/cedarvalley > > > -- > > > Stephen D. Wells > -- > Stephen D. Wells -- Aaron Thompson Unix Systems Administrator, College of Natural Science University of Northern Iowa Cedar Falls, IA 50614 "If there's anything more important than my ego around, I want it caught and shot now." -Douglas Adams From wells at cedarnet.org Fri Dec 19 12:51:00 2003 From: wells at cedarnet.org (Stephen D. Wells) Date: Mon Aug 2 21:27:32 2004 Subject: [Cedarvalley] upload problem In-Reply-To: <20031219154229.GF10878@faculty.cns.uni.edu> References: <20031211165413.GW28940@faculty.cns.uni.edu> <20031211195206.GB28940@faculty.cns.uni.edu> <1071681026.21855.83.camel@localhost.localdomain> <20031217171535.GA10878@faculty.cns.uni.edu> <1071698938.21859.382.camel@localhost.localdomain> <20031219154229.GF10878@faculty.cns.uni.edu> Message-ID: <1071859860.7644.6.camel@localhost.localdomain> try this: ----
upload file:
---- upload.cgi ---- #!/usr/bin/perl -w use strict; use CGI; my $q = CGI->new; my $ret = upload($q, 'upload_file', { upload_path => './uploads', overwrite => 1 }); print "Content-type: text/html\n\n"; # error? if ($ret->{err}) { print $ret->{err}; exit; } # successful print<<" EOS";

$$ret{filename} of size $$ret{length} bytes was uploaded.

EOS exit 1; ########### # input: query, file upload entry name, Attributes # current attributes: upload_path => 'path that files are to be uploaded to # overwrite => 1 or 0 to replace a file or not # output: hash reference of... # filename => the final filename that was used for the upload # length => the size (in bytes) of the uploaded file sub upload { my ($q, $file, $attrib) = @_; # init $attrib->{overwrite} ||= 0; $attrib->{upload_path} ||= '.'; # current directory my $output = {}; my ($filename) = ($q->param($file) =~ /.*[\/\\](.*)$/); my $FH = $q->upload($file); # if the file exists and we aren't allowed to overwrite it... return {err => 'file exists' } if (-e "$$attrib{upload_path}/$filename" && !$attrib->{overwrite}); # upload the file $output->{filename} = $filename; open (OUTFILE,">$$attrib{upload_path}/$filename") || return {err => "can't create: $$attrib{upload_path}/$filename: $!"}; # should you lock the file here? my $buffer; binmode(OUTFILE); while (read($FH,$buffer,1024)) { print OUTFILE $buffer; $output->{length} += length($buffer); } close (OUTFILE); $output } ------ On Fri, 2003-12-19 at 09:42, Aaron Thompson wrote: > The problem seems to be that it doesn't work with Mozilla 1.5 or IE 6 but works > fine with NS 4.7 (I don't have a copy of a new NS browser to test with). > > Here is the code/html: > > Thanks for your help. > > > ---------- > ... > sub upload_file{ > my $overwrite = "1"; #overwrite files on upload (yes = 1, no = 0) > my $length = 0; > my $file = $query->param("upload-me"); > my $local_file_name = ""; > my $uploadFH; > my $save_flag; > > $file =~ s/.*[\/\\](.*)/$1/; > $local_file_name = $tmp_dir . "/" .$file; > print "

File Upload...
This may take some time, please wait...

"; > print "

Attempting to upload: $file

"; > $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 "

$file of size $length bytes was uploaded.

"; > } > else{ > print "

$file already exists... could not upload.

"; > }#fi > } > ... > ---------- > > ---------- > > > server.domain > > > > > > > > > > > > > > > > > > > >
Upload a gallery for aaron
> NOTE: The following limitations will apply when using this tool... >
    >
  • this will only work with .zip files
  • >
  • you should not have any spaces in your image files or zip file.
  • >
  • Once you agree to send the data nothing will display untill the transfer is complete.
  • >
>
>
> > > > > > > > >
upload file:
>
> >
>
>
> Edit Galleries >
> > > ---------- > > > > On Wed, Dec 17, 2003 at 04:08:58PM -0600, Stephen D. Wells wrote: > > If I understand you right it works with netscape but not mozilla... Do > > you have a small complete example (including your html) somewhere? > > > > STEVE > > > > On Wed, 2003-12-17 at 11:15, Aaron Thompson wrote: > > > oh yes... I'm not quite sure what I'm doing wrong. > > > > > > @ > > > > > > On Wed, Dec 17, 2003 at 11:10:27AM -0600, Stephen D. Wells wrote: > > > > I'm back home now and can email again... for some reason the web-based > > > > mailer I was using wasn't sending out - I'm back to evolution now though > > > > and things are back to normal. Is this still an issue? > > > > > > > > STEVE > > > > > > > > On Thu, 2003-12-11 at 13:52, Aaron Thompson wrote: > > > > > 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 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: > > > > > > ------ > > > > > > 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 "

File Upload...
This may take some time, please wait...

"; > > > > > > print "

Attempting to upload: $file

"; > > > > > > 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 "

$file of size $length bytes was uploaded.

"; > > > > > > }else{ > > > > > > print "

$file already exists on the server - not uploaded.

"; > > > > > > }#fi > > > > > > } > > > > > > else{ > > > > > > print "

File not saved... unallowed file time: $mime

"; > > > > > > }#fi > > > > > > } > > > > > > > > > > > > ------ > > > > > > > > > > > > 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@mail.pm.org > > > > > > http://mail.pm.org/mailman/listinfo/cedarvalley > > > > -- > > > > Stephen D. Wells > > -- > > Stephen D. Wells -- Stephen D. Wells