Apache-ASP

 view release on metacpan or  search on metacpan

site/cgi.html  view on Meta::CPAN

<font face="courier new" size=3><pre>
</pre></font>For more information about CGI.pm, please see the web site
<font face="courier new" size=3><pre>
  <a href=http://search.cpan.org/dist/CGI/>http://search.cpan.org/dist/CGI/</a>
</pre></font>
	
	<p>
	<a name=Query%20Object4fef5875></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>Query Object Initialization</b></font>
<font face="courier new" size=3><pre>
</pre></font>You may create a <a href=http://stein.cshl.org/WWW/software/CGI/cgi_docs.html><font size=-1 face=verdana><b>CGI.pm</b></font></a> $query object like so:
<font face="courier new" size=3><pre>
	use CGI;
	my $query = new CGI;
</pre></font>As of Apache::ASP version 0.09, form input may be read in 
by CGI.pm upon initialization.  Before, Apache::ASP would 
consume the form input when reading into $Request-&gt;Form(), 
but now form input is cached, and may be used by CGI.pm input
routines.</font>
	
	<p>
	<a name=CGI%20headers></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>CGI headers</b></font>
<font face="courier new" size=3><pre>
</pre></font>Not only can you use the <a href=http://stein.cshl.org/WWW/software/CGI/cgi_docs.html><font size=-1 face=verdana><b>CGI.pm</b></font></a> $query-&gt;header() method
to put out headers, but with the CgiHeaders config option
set to true, you can also print &quot;Header: value\n&quot;, and add 
similar lines to the top of your script, like:
<font face="courier new" size=3><pre>
 Some-Header: Value
 Some-Other: OtherValue

 &lt;html&gt;&lt;body&gt; Script body starts here.
</pre></font>Once there are no longer any cgi style headers, or the 
there is a newline, the body of the script begins. So
if you just had an asp script like:
<font face="courier new" size=3><pre>
    print join(&quot;:&quot;, %{$Request-&gt;QueryString});
</pre></font>You would likely end up with no output, as that line is
interpreted as a header because of the semicolon.  When doing
basic debugging, as long as you start the page with &lt;html&gt;
you will avoid this problem.</font>
	
	<p>
	<a name=print%28%29ing%20C99232b52></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>print()ing CGI</b></font>
<font face="courier new" size=3><pre>
</pre></font>CGI is notorious for its print() statements, and the functions in CGI.pm 
usually return strings to print().  You can do this under Apache::ASP,
since print just aliases to $Response-&gt;Write().  Note that $| has no
affect.
<font face="courier new" size=3><pre>
	print $query-&gt;header();
	print $query-&gt;start_form();
</pre></font>
	
	<p>
	<a name=File%20Upload></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>File Upload</b></font>
<font face="courier new" size=3><pre>
</pre></font>CGI.pm is used for implementing reading the input from file upload.  You
may create the file upload form however you wish, and then the 
data may be recovered from the file upload by using $Request-&gt;Form().
Data from a file upload gets written to a file handle, that may in
turn be read from.  The original file name that was uploaded is the 
name of the file handle.
<font face="courier new" size=3><pre>
	my $filehandle = $Request-&gt;Form(&#39;file_upload_field_name&#39;);
	print $filehandle; # will get you the file name
	my $data;
	while(read($filehandle, $data, 1024)) {
		# data from the uploaded file read into $data
	};
</pre></font>Please see the docs on CGI.pm (try perldoc CGI) for more information
on this topic, and <a href=eg/file_upload.asp>./site/eg/file_upload.asp</a> for an example of its use.
Also, for more details about CGI.pm itself, please see the web site:
<font face="courier new" size=3><pre>
    <a href=http://search.cpan.org/dist/CGI/>http://search.cpan.org/dist/CGI/</a>
</pre></font>Occasionally, a newer version of CGI.pm will be released which breaks
file upload compatibility with Apache::ASP.  If you find this to occur,
then you might consider downgrading to a version that works.  For example,
one can install a working CGI.pm v2.78 for a working version, and to 
get old versions of this module, one can go to BACKPAN at:
<font face="courier new" size=3><pre>
    <a href=http://backpan.cpan.org/modules/by-authors/id/L/LD/LDS/>http://backpan.cpan.org/modules/by-authors/id/L/LD/LDS/</a>
</pre></font>There is also $Request-&gt;FileUpload() API extension that you can use to get 
more data about a file upload, so that the following properties are
available for querying:
<font face="courier new" size=3><pre>
  my $file_upload = $Request-&gt;{FileUpload}{upload_field};
  $file_upload-&gt;{BrowserFile}
  $file_upload-&gt;{FileHandle}
  $file_upload-&gt;{ContentType}

  # only if FileUploadTemp is set
  $file_upload-&gt;{TempFile}	

  # whatever mime headers are sent with the file upload
  # just &quot;keys %$file_upload&quot; to find out
  $file_upload-&gt;{?Mime-Header?}
</pre></font>Please see the $Request section in <a href=objects.html><font size=-1 face=verdana><b>OBJECTS</b></font></a> for more information.</font>
	

</font>
</td>

<td bgcolor=white valign=top>
&nbsp;
</td>

</tr>
</table>

</td></tr>
</table>
</center>

</body>
</html>



( run in 1.891 second using v1.01-cache-2.11-cpan-b16cb0d3907 )