giving 2 options for Multipart Forms

I have the user enter a filename and then call the "multiprice" program when s/he hits the "Price Summary" button:

<form method="POST" enctype="multipart/form-data"
        action="/cgi-bin/$Area/multiprice">
<p><center>
Enter Filename: <input type="FILE" size=40 name="filename">
</center>
<p><center>
<input type="SUBMIT" value="Price Summary">
</center>
</form>

Now I want to have a second button that calls a different program which will use the same input file.  What is the best way to do this?

Thanks - BB
borghardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

maneshrCommented:
will the 2nd button be on the same page as the fist button??

if yes, how will you control the user input and see to it that he/she first "Uploads" the file and then clicks on the 2nd button.

That apart, in order to have 2 buttons do 2 diff things you need to put the 2nd button in the form tag.

so your program would continue this way...
........................
<input type="SUBMIT" value="Price Summary">
</center>
</form>

<form action="something" action="POST">
<input type="SUBMIT" value="Do this now!!">
</form>
0
borghardAuthor Commented:
I would like the 2nd button on the same page as the first.  I guess my dilemma is: I want the user to enter the filename s/he wants to upload.  Then if button1 is clicked, a program is called and it will upload the file and do some stuff.  If button2 is clicked a different program is called that will also upload the file and do different stuff.

Maybe I should just repeat the multipart/form-data so I have 2 areas to enter a filename? or run in 2 steps: upload the file then ask the user what they want to do.

BB

0
borghardAuthor Commented:
.. or instead of having 2 buttons, maybe I could have onesubmit  button and a pair of radio buttons.  Tthen somehow pass a flag to the called program so it knows which radio button was chosen?

0
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

maneshrCommented:
try this...

=========upload.html===============
<form ENCTYPE="multipart/form-data" action="/cgi-bin/2upload.pl" Method=POST>
Attach:<input name="doc" type="file">
<BR>
<BR>
<INPUT TYPE=SUBMIT NAME=action VALUE="Upload Only!">
<INPUT TYPE=SUBMIT NAME=action VALUE="Upload & Display!">
</form>


=========upload.pl====================
#!/usr/local/bin/perl

use CGI;

$query=new CGI;
$action=$query->param('action');
$DocLocation=$query->param('doc');

$WebFileName = "UpdateGroupFile.htm";

open(MYFILE,"> /tmp/$WebFileName") || die $!;
binmode MYFILE;
while($bytesread=read($DocLocation,$data,1024)){
  $size+=$bytesread;
  print MYFILE $data;
}
close(MYFILE);
close($DocLocation);

`chmod 777 /tmp/$WebFileName`;

print "Content-type: text/html\n\n";
if ($action=~ /^Upload Only\!$/){  ## Called when user clicks "Upload Only !" button
  print "File has been uploaded!<BR>";
  print "Size is $size bytes<br>\n";
}else{ ## Called when user clicks "Upload & Display!" button
  print "File has been uploaded!<br>";

  print "Here it is<br>\n";
  print "<PRE>\n";
  open(IN," /tmp/$WebFileName") || die $!;
  while(<IN>){
    print $_;
  }
  close(IN);
  print "</PRE>\n";
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
borghardAuthor Commented:
.. or instead of having 2 buttons, maybe I could have onesubmit  button and a pair of radio buttons.  Tthen somehow pass a flag to the called program so it knows which radio button was chosen?

0
borghardAuthor Commented:
Thanks!
BB
0
maneshrCommented:
sure. that would work too.

for that all that you need to change is the html file. you script will remain unchanged!!

===========upload.html===========

<form ENCTYPE="multipart/form-data" action="/cgi-bin/2upload.pl" Method=POST>
Attach:<input name="doc" type="file">
<BR>
<BR>
<INPUT TYPE=RADIO NAME=action VALUE="Upload Only!">Upload Only!<BR>
<INPUT TYPE=RADIO NAME=action VALUE="Upload & Display!">Upload & Display!
<P>
<INPUT TYPE=SUBMIT VALUE="Submit">
</form>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.