Ciao a tutti,
Sto impazzendo su un problema che, date le mie scarse conoscenze di php, non mi dà pace:
ho creato una maschera di upload file e funziona perfettamente, ma avrei bisogno di far inviare i file che carico sul server in sottocartelle specifiche a seconda dell'estensione (ad esempio, per un file .zip, invia alla cartella "files zip") è possibile fare una cosa del genere?
ho provato ad inserire delle variabili con i nomi delle cartelle, ma non so come richiamarli a seconda dell'estensione, per l'appunto..pensavo di metterla all'interno della variabile $file ma non so come..vi posto il codice della maschera di upload:

<?php

class maxUpload{
var $uploadLocation;
var $dir='c:\\programmi\\EasyPHP 2.0b1\\www\\consegne\\';
var $subdir1='files jpg';
var $subdir2='files zip';
var $subdir3='files dwg';
var $file=' ';

/**
* Constructor to initialize class varaibles
* The uploadLocation will be set to the actual
* working directory
*
* @return maxUpload
*/
function maxUpload(){
if(($_FILES[substr($file),-3,1])=='.zip'){
$this->uploadLocation = 'c:\\programmi\\EasyPHP 2.0b1\\www\\consegne\\';
}
}
/**
* This function sets the directory where to upload the file
* In case of Windows server use the form: c:\\temp\\
* In case of Unix server use the form: /tmp/
*
* @param String Directory where to store the files
*/
function setUploadLocation($dir){
$this->uploadLocation = $dir;
}
function showUploadForm($msg='',$error=''){
?>
<div id="container">
<div id="header"><div id="header_left"></div>
<div id="header_main">Upload Service </div>
<div id="header_right"></div></div>
<div id="content">
<?php
if ($msg != ''){
echo '<p class="msg">'.$msg.'</p>';
} else if ($error != ''){
echo '<p class="emsg">'.$error.'</p>';

}
?>
<form action="" method="post" enctype="multipart/form-data" >
<center>
<label>File:
<input name="myfile" type="file" size="30" />
</label>
<label>
<input type="submit" name="submitBtn" class="sbtn" value="Upload" />
</label>
</center>
</form>
</div>
<div id="footer">Powered by Mysite</div>
</div>
<?php
}

function uploadFile(){
if (!isset($_POST['submitBtn'])){
$this->showUploadForm();
} else {
$msg = '';
$error = '';

//Check destination directory
if (!file_exists($this->uploadLocation)){
$error = "La cartella di destinazione non esiste!";
} else if (!is_writeable($this->uploadLocation)) {
$error = "La cartella di destinazione è di sola lettura!";
} else {
$target_path = $this->uploadLocation . basename( $_FILES['myfile']['name']);

if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
$msg =basename( $_FILES['myfile']['name']).
" inviato con successo";
} else{
$error = "Errore! trasferimento non riuscito";
}
}

$this->showUploadForm($msg,$error);
}

}

}
?>
Grazie a chiunque possa aiutarmi!