PHP example |
![]() ![]() ![]() |
The example below demonstrates how using a PHP script you can process files submitted by HTTP File Upload Applet. The source code for this example may be found in the examples/php/receiver.php file included with the HTTP File Upload Applet distribution.
Example
<?
// define upload directory, notice that permissions to write are needed for upload directory
$uploaddir = '/var/uploads/';
// get upload filename
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
// add Connection: close header
header("Connection: close");
// move uploaded file from temporary location to upload directory
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
//if succeeded, print out the "success" code to notify applet the file was uploaded
echo "RESP.100";
} else {
//if failed for some reason, print out the "failed" code to notify applet the file wasn't uploaded
echo "RESP.200";
}
?>
Installation
1. | Change $uploaddir variable in receiver.php script to point to directory path where file should be uploaded. Make sure to include a / at the end. |
2. | Upload receiver.php to your web server in a directory that is accessible. |
3. | Set url parameter in HTML applet code to point to url of this script e.g. http://www.mydomain.com/receiver.php |
4. | Done. You may now run HTTP File Upload Applet |
See also