Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: cgi question - using an image button for filefield

by martymart (Deacon)
on Nov 15, 2004 at 14:55 UTC ( [id://407832]=note: print w/replies, xml ) Need Help??


in reply to Re^2: cgi question - using an image button for filefield
in thread cgi question - using an image button for filefield

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://407832]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-09-15 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.