ciao, per uplodare i file ho fatto così, ma come levare gli eventuali spazi che ci sono nei nomi dai file, e come obbligare l'utente a uplodare un file che ha un nome di massimo 10 lettere?
Codice PHP:
<?
$extlimit = "yes";
$limitedext = array(".ppt",".xls",".doc",".pdf",".gif",".jpg");
$sizelimit = "yes";
$sizebytes = "5000000";
$dl = "http://www.sito.it/agenti_file";
$absolute_path = "/web/htdocs/www.sito.it/home/agenti_file";
?>
<?
if ($pagina==1){
$dir = "dir";
if ($file != "") {
$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
$msg = "Il file che stai pubblicando non ha un'estensione corretta";
}
else if (file_exists("$absolute_path/$file_name")) {
$msg = "C'è già un file con lo stesso nome";
}
else if (($sizelimit == "yes") && ($file_size > $sizebytes)) {
$msg = "Il file è troppo grande. Deve essere di $sizebytes bytes o meno";
}
else {
copy($_FILES['file']['tmp_name'], "$absolute_path/$file_name") or die("Il file che stai pubblicando non può essere copiato sul server");
$stringa13="INSERT INTO c_upload_file (file,id_agenti_ins_file,data_ins_file,ora_ins_file) VALUES ('$file_name', '$id_agenti_ins_file', curdate(), curtime())";
$rs_query13=mysql_query($stringa13);
$msg = "Il file è stato pubblicato";
}
} else {
$msg = "Devi selezionare un file da pubblicare";
}
}
?>