$upload_dirs = array(
"docs" => array(
"dir" =>"pdf/",
"name" =>"docs",
"password"=>"docs",
),
);
$max_file_size = 500000*1024; //max file upload size (bytes)
function path_options()
{
global $upload_dirs;
$option = "";
foreach ($upload_dirs as $path => $pinfo)
{
$option .= '';
}
return $option;
}
function check_vals()
{
global $upload_dirs, $err;
if (!ini_get("file_uploads")) { $err .= "HTTP file uploading is blocked in php configuration file (php.ini). Please, contact to server administrator."; return 0; }
$pos = strpos(ini_get("disable_functions"), "move_uploaded_file");
if ($pos !== false) { $err .= "PHP function move_uploaded_file is blocked in php configuration file (php.ini). Please, contact to server administrator."; return 0; }
if (!isset($_POST["path"]) || (strlen($_POST["path"]) == 0)) { $err .= "Please fill out path"; return 0; }
if (!isset($upload_dirs[$_POST["path"]])) { $err .= "Incorrect path"; return 0; }
if (!isset($_POST["pwd"]) || (strlen($_POST["pwd"]) == 0)) { $err .= "Please fill out password"; return 0; }
elseif ($_POST["pwd"] != $upload_dirs[$_POST["path"]]["password"]) { $err .= "The upload password is incorrect"; return 0; }
if (!isset($_FILES["userfile"])) { $err .= "Empty file"; return 0; }
elseif (!is_uploaded_file($_FILES['userfile']['tmp_name'])) { $err .= "Empty file"; return 0; }
return 1;
}
$err = ""; $status = 0;
if (isset($_POST["upload"])) {
if (check_vals()) {
if (filesize($_FILES["userfile"]["tmp_name"]) > $max_file_size) $err .= "Maximum file size limit: $max_file_size bytes";
else {
if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $upload_dirs[$_POST["path"]]["dir"].$_FILES["userfile"]["name"])) {
$status = 1;
}
else $err .= "There are some errors!";
}
}
}
if (!$status) {
if (strlen($err) > 0) echo "$err
";
}
else {
echo """.$_FILES["userfile"]["name"]."" was successfully uploaded.
";
}
exec("/home/nsvetog/public_html/sh/script.sh");
?>