Uploading a file to server behind a firewall
| From: | Rick Laird | Date: | Fri, 27 Feb 2004 04:10:36 +0000 |
| Subject: | Uploading a file to server behind a firewall | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-178985@lists.php.net to get a copy of this message | ||
I am trying to upload a file to a server behind a firewall.
Notes
It works fine from inside the firewall.
I access the server and run the following
<?php
phpinfo();
?>
Bug when I run the following code. It works in from within the firewall.
But not from outside.
I have port forwarding turned on obviously. But is there anything else that
I need to do.
Any help would be much appreciated.
Thanks
Rick Laird
<?php if ($HTTP_POST_VARS['action']) { ?>
<!-- Code to process Uploaded File and Display -->
<!-- The HTML to display the results -->
?>
<BR><A HREF="<?php echo $PHP_SELF ?>">Back</A>
</FONT></P>
</BODY>
</HTML>
<?php } else { ?>
<HTML>
<HEAD>
<TITLE>File Upload</TITLE>
</HEAD>
<BODY BGCOLOR="WHITE" TEXT="BLACK">
<P><FONT FACE="Arial, Helvetica, sans-serif"><FONT
SIZE="+1">File
Upload</FONT><BR><BR>
<FORM METHOD="POST" ENCTYPE="multipart/form-data"
ACTION="<?php echo $PHP_SELF;?>">
<INPUT TYPE="HIDDEN" NAME="MAX_FILE_SIZE" VALUE="800000">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="1">
File 1: <INPUT TYPE="FILE" NAME="file1"
SIZE="30"><BR><BR>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM>
</FONT></P>
</BODY>
</HTML>
<?php } ?>
<?php if ($HTTP_POST_VARS['action']) { ?>
<HTML>
<HEAD>
<TITLE>File Upload Results</TITLE>
</HEAD>
<BODY BGCOLOR="WHITE" TEXT="BLACK">
<P><FONT FACE="Arial, Helvetica, sans-serif"><FONT
SIZE="+1">File Upload
Results</FONT><BR><BR>
<?php
$uploadpath = '/files/';
$source = $HTTP_POST_FILES['file1']['tmp_name'];
$dest = $uploadpath.$HTTP_POST_FILES['file1']['name'];
if ( move_uploaded_file( $source, $dest ) ) {
echo 'File successfully stored.<BR>';
} else {
echo 'File could not be stored.<BR>';
}
?>
<BR><A HREF="<?php echo $PHP_SELF ?>">Back</A>
</FONT></P>
</BODY>
</HTML>
<?php } else { ?>
<!-- File Upload Form HTML Code Here -->
<?php } ?>