LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cgi - no access to the keys of the keyed array after *.-txt-file-upload - where is the mistake?

Hello,


I use LabView 8.2 including the Internet Toolkit. To process form data I use the G WebServer.


In the context of CGI-programming I have the following problem:

Using a html-form (code see below) I want to send two numbers and a *.txt-file to a CGI VI (cgi-test.vi). Afterwards this vi sends the sum of the two numbers and the content of the *.txt-file back to the user.

The html-code of the form looks like as follows:


<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body bgcolor="#FFFFFF" text="#000000">

<p><font size="5"><b>CGI-Test - addition of two numbers</b></font></p>

<hr>

<p>This form adds two numbers and displays the sum as well as the content of the uploaded *.txt-file.</p>

<form name="form1" method="post" action="/cgi-bin/cgi-test" enctype="multipart/form-data">

  <p> Number 1 

    <input type="text" name="n1">

  </p>

  <p>Number 2 

    <input type="text" name="n2">

  </p>

  <p> 

    <input type="file" name="f1">

  </p>

  <p> 

    <input type="submit" name="submit" value="submit">

    <input type="reset" name="reset" value="reset">

  </p>

</form>

<p>&nbsp;</p>

</body>
</html>

 

Pressing the submit button evokes the transmission of the data to cgi-test.vi. Theoretically afterwards the keyed array has to be disaggregated in its single components, facilitating further processing of the submitted data (i.e. calculation of the sum of the two numbers as well as displaying the content of the *.txt-file). However I get the following result:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Draft//EN">

<HTML>

<!-- Constructed with the G Web Server -->

<HEAD>

<TITLE>CGI-Test</TITLE>

</HEAD>

 

<BODY >

Summe:

0File content:

 

</BODY>
</HTML>

 

 

I don't know why the three submitted data (n1, n2, f1) obviously cannot be break down and why the further processing leads to a inconvenient result.


My questions are:

1. How can I break down the three data so that I can call them independently from each other?

Why doesn't the "keyed array index.vi" work correctly?

2. Is there a mistake in my html-form?

3. Are there some cgi-template-vi's on the web, which process uploaded file content?


Thanks alot in advance for your help!!!
Ulrich

 

The cgi-test.vi looks like as follows:

0 Kudos
Message 1 of 8
(4,294 Views)
Hi Ulrich,

have you allready updated your Internet Toolkit?
There are some problems mentioned using CGI which are solved by a patch.
You can find this patch here:
http://digital.ni.com/softlib.nsf/websearch/0A20303193EFCD53862570B3007CC48C?opendocument&node=132070_US

For examples, please refer to \..National Instruments\LabVIEW 8.2\www\cgi-bin\examples


Please let me know, if your CGI conversation works proper after updating the toolkit

regards
Kilian
0 Kudos
Message 2 of 8
(4,268 Views)
Hi Kilian,

thanks alot for your help! Unfortunately the problem still remains after updating the internet toolkit.
Do you know a good source for CGI-example-vi's showing the way to process/disaggregate parameters and files uploaded by a html-form or do you have own ideas how to solve my problem?

Best wishes and many thanks for your help,
Ulrich
0 Kudos
Message 3 of 8
(4,261 Views)
Hi Ulrich,

please try to use an example shipped with the Internet Toolkit.
You can acces all these examples executing the following steps:
1. Start the G Web Server (in LabVIEW-->Tools-->Internet Toolkit-->Start G Web Server...)
2. Launch your webbroser and use http://localhost as URL

So please launch one or more examples and see if they work proper.
If they work, there is an underlying problem in your project, if they wont work, we have to examine your Web Server configuration.

Regards
Kilian
0 Kudos
Message 4 of 8
(4,255 Views)
Hi Kilian,

I tried the following examples shipped with the Internet Toolkit:
- CGI Call With Multiple Parameters (POST)
- Comments CGI
- Run Test CGI
- Counter CGI
All of them worked very well. So I think there is no problem with the G Web Server settings.
I think the problem is localized in my own vi. But I absolutely have no idea what the problem is. In the attachment you can find the vi (cgi-test_10.vi) and a text file (text-file.txt). At the bottom of this message you see the html-form I use to submit my data to the CGI VI. So you can try it locally on your computer and see the problem I mean. My impression is that the upload of the parameters and the file works well, but the problem is the decryption of the submitted content.

Best regards,
Ulrich

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p><font size="5"><b>CGI-Test - addition of two numbers</b></font></p>
<hr>
<p>This form adds two numbers and displays the sum as well as the content of the uploaded *.txt-file.</p>
<form name="form1" method="post" action="/cgi-bin/cgi-test_10.vi" enctype="multipart/form-data">
<p> Number 1
<input type="text" name="n1">
  </p>
<p>Number 2
<input type="text" name="n2">
</p>
<p>
<input type="file" name="f1">
</p>
<p>
<input type="submit" name="submit" value="submit">
<input type="reset" name="reset" value="reset">
  </p>
</form>
<p>&nbsp;</p>
</body>
</html>

Message Edited by ulrichmayer on 05-21-2007 11:39 AM

Message Edited by ulrichmayer on 05-21-2007 11:40 AM

Download All
0 Kudos
Message 5 of 8
(4,248 Views)
Hi Ulrich,

I tested the attached VI and I get the two different numbers and the text written in the textfile. But not in the expected form.
Using the VI you attached in your first post (rebuilt from the sreenshot) I do not get any data.
Means that I get the same empty html document you've posted above.

Until now we sadly do not know why this does not work proper. The error should be in the "Index Array" but we have to investigate this problem.

As soon as I have new information, I will post it.

regards
Kilian
0 Kudos
Message 6 of 8
(4,225 Views)
Hi Kilian,

this is exactly the problem. We don't get the expected result.

I would be extremely grateful for your help! Inbetween I will go on searching for the error and post my progress in handling this error here.

Regards,
Ulrich
0 Kudos
Message 7 of 8
(4,219 Views)
Hi Ulrich,

I wrote a small example which reads the keys and I get the expected result.
Please have a look at the attached files, copy them to the referring directories for the G-Web Server and test it.

Please let me know if the result is the  result you expect.

Regards
Kilian

below, you see the source of the .html file I use:

<html>
<body>

<head>
<title>Untitled Document</title>
</head>

<form action="http://localhost/cgi-bin/basic2.vi" method="post">
    <input type="text" name="name1"><br>
    <input type="text" name="name2"><br>
    <input type="file" name="file"><br>
    <input type="submit" name="submit" value="submit">

</body>
</html>

0 Kudos
Message 8 of 8
(4,200 Views)