in reply to cgi question - using an image button for filefield

To do this go here: Quirks mode css site

As you will see - its hardly elegant but if that is what you want :).
  • Comment on Re: cgi question - using an image button for filefield

Replies are listed 'Best First'.
Re^2: cgi question - using an image button for filefield
by Anonymous Monk on Nov 12, 2004 at 16:21 UTC
    Doesn't look elegant at all, is there no other way to do this kind of thing?
    Thanks,
    Jonathan
      Hi Jonathan,

      How about something like this, uses a bit of scripting instead of all that css stuff:
      #!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); #errors will show in the browser my $co=new CGI; print $co->header, $co->start_html( -title=>'fileupload.cgi', -BGCOLOR=>'#FFFFFF', ), $co->start_form( -method=>'POST', -name=>"myForm", -action=> "http://localhost/cgi-bin/fileupload2.cgi", ), $co-> filefield( -name => 'browse', -style => 'display:none' ), $co-> textfield( -name => 'file', ), "&nbsp;&nbsp;&nbsp;&nbsp;", "<a href=\"#\" onClick=\"document.forms[0].browse.click();document.for +ms[0].file.value=document.forms[0].browse.value;return false;\">", "<img name=\"browse\" src=\"http://localhost/html/browse.bmp\" alt=\"b +rowse\" border=\"0\"></a>", $co->p, $co->image_button( -name => 'submit', -src => 'http://localhost/html/add.bmp', -value => "Submit", -onclick => "document.forms[0].browse.disabled=tru +e;document.forms[0].submit()", ), $co->end_form(), $co->end_html; exit 0;
      I've tried this myself and it does appear to work.
      Enjoy,
      Martymart