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




perlperlAsked:
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.

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

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
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
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
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.