| Server IP : 23.94.149.180 / Your IP : 216.73.216.147 Web Server : nginx/1.20.1 System : Linux deadrock 5.14.0-741.22.1.el9_9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 12 15:18:14 UTC 2026 x86_64 User : apache ( 48) PHP Version : 8.6.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /files/www/voxsupport/files/fancy/docs/userguide/HTML/ |
Upload File : |
<html>
<head>
<title>Perl example</title>
<meta name="generator" content="Help & Manual">
<meta name="keywords" content="">
</head>
<!-- Redirect browser to index page if page is not in the content frame.
This script is only valid for regular HTML export -->
<script language="JavaScript">
<!--
if(top.frames.length==0) top.location.href='index.html?perlexample.html'
//-->
</script>
<body bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#E2E2E2">
<tr>
<td align="left">
<span style="font-family:Helvetica,Arial; font-size:12pt; color:#000000"><span style="font-family:Helvetica,Arial; font-size:12pt; color:#000080"><b>Perl example
<br>
</b></span></span>
</td>
<td align="right">
<font face="Arial" size="2">
<a href="javaScript:parent.reDisplay('1.1',1,0)"><img src="ico_nav_up.gif" border=0 alt="Top"></a>
<a href="javaScript:parent.reDisplay('3.2',1,0)"><img src="ico_nav_back.gif" border=0 alt="Previous"></a>
<a href="javaScript:parent.reDisplay('3.4',1,0)"><img src="ico_nav_next.gif" border=0 alt="Next"></a>
</font>
</td>
</tr>
</table>
<br>
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The example below demonstrates how using a Perl script you can process files submitted by HTTP File Upload Applet. The source code for this example may be found in the <span style="font-family:Courier New; font-size:10pt; color:#000000">examples/perl/receiver.pl</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"> file included with the HTTP File Upload Applet distribution.
<br>
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
<br>
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#008000"><b>Example</b></span></span></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
<br>
</span><span style="font-family:Courier New; font-size:10pt; color:#000000"><span style="font-family:Courier New; font-size:10pt; color:#008000">#!/usr/bin/perl</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># use CGI module</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
use CGI;
<br>
use File::Path;
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># define location where uploaded files will be stored, notice that permissions to write are needed </span></span><span style="font-family:Courier New; font-size:10pt; color:#000000"><span style="font-family:Courier New; font-size:10pt; color:#0000FF">for</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000"><span style="font-family:Courier New; font-size:10pt; color:#008000"> upload directory </span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
$uploaddir = <span style="font-family:Courier New; font-size:10pt; color:#000080">'/var/uploads/'</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">;
<br>
$query = <span style="font-family:Courier New; font-size:10pt; color:#0000FF">new</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000"> CGI;
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># parse the name of file</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
$filename = $query->param(<span style="font-family:Courier New; font-size:10pt; color:#000080">"file"</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">);
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># Index where starts the file name </span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
$index = rindex($filename,<span style="font-family:Courier New; font-size:10pt; color:#000080">"\\"</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">);
<br>
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># Gets the directory path name from the file name</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
$dirName = substr($filename, <span style="font-family:Courier New; font-size:10pt; color:#000080">0</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">,$index+<span style="font-family:Courier New; font-size:10pt; color:#000080">1</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">);
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># Check the directory name</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
<span style="font-family:Courier New; font-size:10pt; color:#0000FF">if</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">($dirName ne <span style="font-family:Courier New; font-size:10pt; color:#000080">""</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">){
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># Concat the directory path name </span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
$uploaddir = $uploaddir . $dirName;
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># Make the directory </span></span><span style="font-family:Courier New; font-size:10pt; color:#000000"><span style="font-family:Courier New; font-size:10pt; color:#0000FF">if</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000"><span style="font-family:Courier New; font-size:10pt; color:#008000"> it does not exist</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
<span style="font-family:Courier New; font-size:10pt; color:#0000FF">if</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">(! -d $uploaddir){
<br>
mkpath $uploaddir;
<br>
}
<br>
}
<br>
<br>
$filename =~ s/.*[\/\\](.*)/$1/;
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># gets file handle</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
$upload_filehandle = $query->upload(<span style="font-family:Courier New; font-size:10pt; color:#000080">"file"</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">);
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># reads contents and saves it out</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
open UPLOADFILE, <span style="font-family:Courier New; font-size:10pt; color:#000080">">$uploaddir/$filename"</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000"> || &upload_error;
<br>
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># tells Perl to write the file in binary mode, rather than in text mode. </span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
binmode UPLOADFILE;
<br>
<span style="font-family:Courier New; font-size:10pt; color:#0000FF">while</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000"> ( <$upload_filehandle> ) {
<br>
print UPLOADFILE;
<br>
}
<br>
<span style="font-family:Courier New; font-size:10pt; color:#008000"># close the file</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
close UPLOADFILE;
<br>
<br>
print $query->header();
<br>
print <span style="font-family:Courier New; font-size:10pt; color:#000080">"RESP.100"</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">;
<br>
<br>
sub upload_error {
<br>
print INFO <span style="font-family:Courier New; font-size:10pt; color:#000080">"****ES ERROR***\n"</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">;
<br>
print <span style="font-family:Courier New; font-size:10pt; color:#000080">"RESP.200"</span></span><span style="font-family:Courier New; font-size:10pt; color:#000000">;
<br>
exit;
<br>
}
<br>
<br>
</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><b>Installation</b>
<br>
<br>
</span></span><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="28"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">1.</span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">Change <span style="font-family:Courier New; font-size:10pt; color:#000000">$upload_dir</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"> variable in </span><span style="font-family:Courier New; font-size:10pt; color:#000000">receiver.pl</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"> script to point to directory path where file should be uploaded. DO NOT include a </span><span style="font-family:Courier New; font-size:10pt; color:#000000">/</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"> at the end of this path.
<br>
</span></span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="28"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">2.</span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">Upload receiver.pl to the CGI directory on your web server. Typically this directory is named <span style="font-family:Courier New; font-size:10pt; color:#000000">cgi-bin</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">. Please consult your system administrator if you are unsure where this directory is located.
<br>
</span></span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="28"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">3.</span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">Add execute permissions to the <span style="font-family:Courier New; font-size:10pt; color:#000000">receiver.pl</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"> script. You can do this by connecting to the web server using telnet or ssh, navigating to the CGI directory and issuing the command </span><span style="font-family:Courier New; font-size:10pt; color:#000000">chmod 755 receiver.pl</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
</span></span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="28"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">4.</span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">Set <span style="font-family:Courier New; font-size:10pt; color:#000000">url</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"> parameter in HTML applet code to point to url of this script e.g. </span><span style="font-family:Courier New; font-size:10pt; color:#000000">http://www.jscape.com/cgi-bin/receiver.pl</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
</span></span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="28"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">5.</span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">Done. You may now run HTTP File Upload Applet
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"></span></td><td></td></tr></table><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><span style="font-family:Courier New; font-size:10pt; color:#000000">
<br>
<span style="font-family:Courier New; font-size:10pt; color:#000000"></span></span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><b>See also</b>
<br>
<br>
</span></span><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=javaScript:parent.reDisplay('2.8',1,0)>Specifying the upload URL</a>
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"></span></td></tr></table><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
</span>
</body>
</html>