<?php
// This script should be called /muon1/uploadresults.php on your web (HTTP) server
// Set the path below to the root of your Muon1 FTP directory
$ftproot='c:/website/ftp/';
// Note that the FTP (upload) and HTTP spaces should NOT overlap, for security reasons!
function h($s) {header($s); echo "<html><body><h1>$s</h1></body></html>";}
if ($f=$_FILES['data'])
{
if (strstr($_SERVER['CONTENT_TYPE'],'Muon1') && $_POST['folder']) switch ($f['error'])
{
case UPLOAD_ERR_OK:
$dest=$ftproot.$_POST['folder'].'/'.$f['name'];
$dest=str_replace('../','',$dest);
if (!file_exists($dest))
{
if (move_uploaded_file($f['tmp_name'],$dest)) h('HTTP/1.1 200 OK (file uploaded successfully)');
else h('HTTP/1.1 500 Server Error (cannot move uploaded file from tmp folder to '.$dest.')');
}
else h('HTTP/1.1 403 Forbidden (will not overwrite existing file)');
break;
case UPLOAD_ERR_INI_SIZE: h('HTTP/1.1 413 Request Entity Too Large (exceeds upload_max_filesize directive in php.ini)'); break;
case UPLOAD_ERR_FORM_SIZE: h('HTTP/1.1 413 Request Entity Too Large (exceeds MAX_FILE_SIZE directive in the HTML form)'); break;
case UPLOAD_ERR_PARTIAL: h('HTTP/1.1 500 Server Error (file only partially uploaded)'); break;
case UPLOAD_ERR_NO_FILE: h('HTTP/1.1 500 Server Error (no file was uploaded)'); break;
case UPLOAD_ERR_NO_TMP_DIR: h('HTTP/1.1 500 Server Error (no upload_tmp_dir given in php.ini)'); break;
case UPLOAD_ERR_CANT_WRITE: h('HTTP/1.1 500 Server Error (failed to write file to disk)'); break;
default: h('HTTP/1.1 500 Server Error (unknown error!)'); break;
}
else h('HTTP/1.1 403 Forbidden (upload not from Muon1 client)');
}
else h('HTTP/1.1 403 Forbidden (not a file upload)');
?>