in reply to Re^2: cgi question - using an image button for filefield
in thread cgi question - using an image button for filefield
I've tried this myself and it does appear to work.#!/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', ), " ", "<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;
|
|---|