• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

submit

i tried this to auto submit form using cgi ....not working

#!c:/perl/bin/Perl.exe
use CGI;


print "Content-type: text/html; charset=iso-8859-1 \n\n";
$|=1;

#Declare Args

$query    = new CGI;
$file = $query->param('upload_file');


 print <<HTML;
   <html>
      <body>
      <form name=form1 method=post action="t1.cgi?merge=0&upload_file=$file"/>
      <input type=submit name=submit value=go>
      </body>
<script >
    document.form1.submit();
</script>

</html>
HTML




0
perlperl
Asked:
perlperl
  • 9
  • 8
1 Solution
 
ZvonkoSystems architectCommented:
Event when you get submit() to work, do you realy think you can autosubmit a user file from users disk? Why not take his password.txt and his credit card cookie files?
As soon as you have input type=file on the form does autosubmit not work.
And that security feature is even not necessary because you cannot set the value of a form field of type=file
And without a field of type=file you CANNOT upload files to server.


0
 
perlperlAuthor Commented:
the reason i thought is because....this is not working for me
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21821039.html
0
 
ZvonkoSystems architectCommented:
Do you notice that we turn in circles?

OK, let us start from scratch. Now I ask you one question and you give me one answer.

Question: Is this sequence possible on a page: Perl executes, then some JavaScript executes, then again does Perl finish its work after JavaScript has finished the execution. Is that possible on one single CGI page?

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
perlperlAuthor Commented:
Let me give u the sequence I am looking

1) html page with couple of form elements...on submit gets redirected to  test.cgi
2) test.cgi checks if the file exists or not. it should prompt user to confirm()
    if user says yes, redirect to blah.cgi with parameter merge=1  else
    redirect to blah.cgi with merge=0...

problem is i does get reedirected to blah.cgi, but instead of printing the output in browser window it ask me where iw ant to save the file, when i save, it saves the output in blah.doc file.....................
0
 
perlperlAuthor Commented:
problem is i can't pass javascript variable to cgi script...otherwise life would have been easy for me... :)
0
 
perlperlAuthor Commented:
also the other issue is javascript cannot check if the file exists or not, otherwise life would have been easy for me... :)
0
 
ZvonkoSystems architectCommented:
OK, let me rephrase your scenario.
1.) HTML page with a file upload control form element submits the file to a CGI Perl script: test.cgi
2.) test.cgi get the file in the input stream and has to store that stream as file. If test.cgi does not store the submited input stream is the submited file stream lost and need to be resubmited by user. OK, you store the stream as a temporary file name because you do not want to overwrite the existing file on server side and need a way to ask the user to overwrite or not. The problem is: for one form submit you can run only one CGI and create only one response document. That mean, you cannot stop in test.cgi, ask something the user and then continue the test.cgi from the question point. That is NEVER possible in HTTP (HyperTextTransferProtocol) In http you do one request and get one response. Full stop.

0
 
perlperlAuthor Commented:
well, everything is working fine, except
problem is i does get reedirected to blah.cgi, but instead of printing the output in browser window it ask me where iw ant to save the file, when i save, it saves the output in blah.doc file.....................
0
 
perlperlAuthor Commented:
I hope  I am not confusing you........
0
 
ZvonkoSystems architectCommented:
And yes, JavaScript cannot check user disk on browser side, and it cannot check anything on server side. There is a wall betwean browser and server, and JavaScript has no way to go around the wall except to send an URL request or post form data to some CGI on server side. But as soon as the URL is requested or the form is submitted is the control lost on browser side: nothing can be done after the request is done. The next server response can create some response text that contains new scripts for execution, but previous page script is discarded.



0
 
ZvonkoSystems architectCommented:
You cannot confuse me. Believe me, I am working with computers since 1984 :)
0
 
perlperlAuthor Commented:
have you ever came across this situation

well, everything is working fine, except
problem is i does get reedirected to blah.cgi, but instead of printing the output in browser window it ask me where iw ant to save the file, when i save, it saves the output in blah.doc file.....................
0
 
ZvonkoSystems architectCommented:
Why grade B again?
0
 
perlperlAuthor Commented:
sorry again...............
0
 
ZvonkoSystems architectCommented:
:-)
0
 
perlperlAuthor Commented:
i did in hurry..........i apologize
0
 
ZvonkoSystems architectCommented:
No problem at all.
Did you analyze your test.cgi and blah.cgi chain?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 9
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now