Salve a tutti.
Premetto che il seguente codice è funzionante quando lo testo sul mysql di altervista.
Esso mi permette di caricare un file su una cartella 'utentiimmages' e popolare il campo 'fileupload' nel database con la stringa che rappresenta il percorso del file.
Codice PHP:
.....
$error = "false";
// Array del file inviato
#$fileupload_temp = $_FILES['fileupload']['tmp_name'];
/*$nome_file = $_FILES['file']['name'];
$size_file = $_FILES['file']['size'];
$type_file = $_FILES['file']['type'];
$error_file = $_FILES['file']['error'];*/
$nome_file = $HTTP_POST_FILES['file']['name'];
$size_file = $HTTP_POST_FILES['file']['size'];
$type_file = $HTTP_POST_FILES['file']['type'];
$error_file = $HTTP_POST_FILES['file']['error'];
// Tipo di estenzioni consentite
$MAX_FILE_SIZE = "250000";
$allowed_ext = array("jpg,jpeg,gif");
$allowed_types = array("image/x-png","image/pjpeg","image/jpeg","image/gif");
// Destinazione file da caricare sul server
$target_path= "utentiimmages/".$nome_file;
if ($nome_file!=""){
if ($size_file > $MAX_FILE_SIZE) { // Controllo la dimensione del file
$msg = "File troppo grande";
echo "$msg";
$error = "true";
}elseif (!in_array($type_file, $allowed_types)) { // Controllo l'estenzione del file
$msg = "Il file selezionato non é nella lista dei file consentiti";
echo "$msg";
$error = "true";
}
}
if ($error == "false" or $nome_file==""){
$sql="INSERT INTO Ricetta (IdAutore,TitoloRicetta,ModalitaPreparazione,NumeroPorzioni,CaloriePorzioni,Tipologia,LivelloDifficolta,TempoCottura,fileupload)
VALUES ('$flag','$TitoloRicetta','$ModalitaPreparazione','$NumeroPorzioni','$CaloriePorzioni','$Tipologia','$Difficolta','$Tempo','$target_path' )";
copy($HTTP_POST_FILES['file']['tmp_name'], $target_path);
......
Quando eseguo lo stesso codice su un altro spazio web che non sia altervista, non carica il file, nè popola il campo fileupload con la stringa del percorso di quest'ultimo.
Come posso risolvere?
Grazie.