Ciao! Sto creando un form per l'inserimento di articoli in un database, ed ho due campi file, uno per l'upload di un'immagine e uno per l'upload di un file PDF. Lo script che uso è quello suggerito su freephp.html.it, e che solitamente funziona benissimo. Ma in questo caso mi dice che è impossibile spostare i file, anche se i chmod sono a 777!
Vi posto il codice:
Codice PHP:
if (count($_POST)>0) { //l'array $_POST esiste, quindi vado ad inserire la news

$topnews=trim($_POST['topnews']);
$homepage=trim($_POST['homepage']);
$anno=trim($_POST['anno']);
$mese=trim($_POST['mese']);
$giorno=trim($_POST['giorno']);
$titolo_ita=addslashes(stripslashes(trim($_POST['titolo_ita'])));
$titolo_eng=addslashes(stripslashes(trim($_POST['titolo_eng'])));
$img=addslashes(stripslashes(trim($_POST['img'])));
$alt=trim($_POST['alttxt']);
$testo_ita=addslashes(stripslashes(trim($_POST['testo_ita'])));
$testo_eng=addslashes(stripslashes(trim($_POST['testo_eng'])));
$status_ita=trim($_POST['status_ita']);
$status_eng=trim($_POST['status_eng']);
$download=trim($_POST['download']);
$file=addslashes(stripslashes(trim($_POST['filename'])));
$id_cat=trim($_POST['id_cat']);
$id_gara=trim($_POST['gara']);
$id_champ=trim($_POST['champ']);
                    
$data $anno.'-'.$mese.'-'.$giorno;
                    
$selectid=pg_Exec($conn,"select max(id_news) as id from qc_newstest");
$rowid=pg_Fetch_Array($selectid);
$newid=((int)(trim($rowid['id']))) + 1;
$newid='0'.$newid;
                    
$selectdata=pg_Exec($conn,"select max(data) as data from qc_newstest");
$rowdata=pg_Fetch_Array($selectdata);
$datamax=trim($rowdata['data']);
   if (
$datamax==$data) {
   
$selectord=pg_Exec($conn,"select max(ordine) from qc_newstest where data='$datamax'::date");
   
$roword=pg_Fetch_Array($selectord);
   
$ordine = (trim($roword['ordine'])) + 1;
   } else {
   
$ordine 1;
   }
                    
if (
$_FILES['imgnew']['name']!='') {
                    
$upload_img_dir=$_SERVER['DOCUMENT_ROOT']."/img/news";
$new_img_name=$newid."_img.".substr($_FILES['imgnew']['name'],(strlen($_FILES['imgnew']['name'])-3),3);
$img=$new_img_name;
if (@
is_uploaded_file($_FILES['imgnew']['tmp_name'])) {
@
move_uploaded_file($_FILES['imgnew']['tmp_name'],"$upload_img_dir/$new_img_name")
or die (
"Impossibile spostare il file.");
} else {
die (
"Problemi nell'upload del file.");
}
echo 
"L'upload del file " $_FILES["imgnew"]["name"] . " è avvenuto correttamente";
}
                    
if (
$_FILES['filenamenew']['name']!='') { 
print 
$upload_file_dir=$_SERVER['DOCUMENT_ROOT']."/docs";
print 
$new_file_name=$newid."_file.".substr($_FILES['filenamenew']['name'],(strlen($_FILES['filenamenew']['name'])-3),3);
print 
$file=$new_file_name;
if (@
is_uploaded_file($_FILES['filenamenew']['tmp_name'])) {
@
move_uploaded_file($_FILES['filenamenew']['tmp_name'],"$upload_file_dir/$new_file_name")
or die (
"Impossibile spostare il file.");
} else {
die (
"Problemi nell'upload del file.");
}
echo 
"L'upload del file " $_FILES["filenamenew"]["name"] . " è avvenuto correttamente";
}
                    
$insertnew=pg_Exec($conn,"insert into qc_newstest values ('$newid','$data'::date,'$topnews','$homepage','$status_ita','$ordine','$id_cat','$testo_ita','$testo_eng','$titolo_ita','$titolo_eng','$alt','$id_champ','$img','$download','$file','$status_eng','$id_gara','t')");
                    

help me!!!!!!!!!!!!