ecco vedi se va bene :
Codice PHP:
<?php
define("PASS", "password");
define("USER", "username");
$percorso[] = "immagini/";
$percorso[] = "sfondi/";
$percorso[] = "sfondi/paesaggi/";
error_reporting(0);
$estensione = strtolower(substr($_FILES['fil']['name'], -4));
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="Upload immagini"');
header('HTTP/1.0 401 Unauthorized');
exit;
}elseif($_SERVER['PHP_AUTH_USER'] == USER && $_SERVER['PHP_AUTH_PW'] == PASS && !isset($_FILES['fil'])){
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1" />
<title>Upload</title>
</head>
<body>
<form method="post" enctype="multipart/form-data" />
<input type="file" name="fil" size="30" /><br />
<input type="submit" name="Submit" value="Invia" />
<fieldset>
<legend>Percorso</legend>
<select name="path" >
<option value="0" selected="selected">immagini/ </option>
<option value="1">sfondi/ </option>
<option value="2">sfondi/paesaggi/ </option>
</select>
</fieldset>
</form>
</body>
</html>
<?
}elseif($_SERVER['PHP_AUTH_USER'] == USER && $_SERVER['PHP_AUTH_PW'] == PASS && isset($_FILES['fil']) && ($estensione == ".gif" || $estensione == ".jpg" || $estensione == "jpeg" || $estensione == ".png")){
move_uploaded_file($_FILES['fil']['tmp_name'], $percorso[$_POST['path']] . $_FILES['fil']['name']) or die("Impossibile Uploadare il file!");
echo "File Uploadato";
}elseif($_SERVER['PHP_AUTH_USER'] == USER && $_SERVER['PHP_AUTH_PW'] == PASS && isset($_FILES['fil'])){
die("Puoi uploadre solo immagini");
}else{
header('HTTP/1.0 403 Forbidden');
}
?>
la grafica fa schifo...