ciao gente.
sto sbattendo la testa su un problema che si presenta all'invio di files sullo spazio web del server che ospita il sito.
in locale tutto funziona benissimo, sul server NO.
il vettore rimane sempre VUOTO.
Codice PHP:
<?php
ini_set('error_reporting',E_ALL);
include_once('conn.inc.php');
$id = $_GET['_addpic'];
$base_dir = "attach/";
$sel_img = "<select name='tipo'><option value='1'>Copertina</option><option value='0' selected>Generale</option></select>";
echo "<fieldset style='width:50%'><legend> Modulo aggiunta immagini alla scheda del velivolo</legend>
<form enctype=\"multipart/form-data\" name='add_pic' method='POST' action='mod_pic.php?_addpic=$id'>
<input type='hidden' name='MAX_FILE_SIZE' value='8388608' />
<input type='file' name='add_p'>
$sel_img
<input type='submit' name='sub_pic' value='Aggiungi immagine'>
</form><font style='font-size: 10pt'>
Ricorda di impostare almeno un'immagine come [b]Copertina[/b] ovvero come immagine che verrà visualizzata di fianco al link nella pagina principale. Scegline una evocativa!.</font></fieldset>
<fieldset style='width:50%'>[url='pagine.php?mod=$id']Torna alla scheda del velivolo[/url]</fieldset><hr style='align: center; width: 70%'>";
...
if(isset($_POST['sub_pic']) && $_POST['sub_pic'] == 'Aggiungi immagine' ){
echo "<pre>";
print_r($_FILES);
$id = $_GET['_addpic'];
$tipo = $_POST['tipo'];
$img = $_FILES['add_p']['name'];
if($_FILES['add_p']['error'] == 0){
$ext = $_FILES['add_p']['type'];
echo "ESTENSIONE: ".$ext;
$uploadedfile = $_FILES['add_p']['tmp_name'];
$up_dir = $base_dir.$img;
list($width,$height) = getimagesize($uploadedfile);
if($ext == "image/pjpeg" || $ext == "image/jpeg"){
$src = imagecreatefromjpeg($uploadedfile);
}
elseif($ext == "image/x-png" || $ext == "image/png"){
$src = imagecreatefrompng($uploadedfile);
}
elseif($ext == "image/gif"){
$src = imagecreatefromgif($uploadedfile);
}
$newwidth = 200;
$newheight = ($height/$width)*200;
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$thumb_path= $base_dir."/thumbs/".$img;
imagejpeg($tmp,$thumb_path,80);
imagedestroy($src);
imagedestroy($tmp);
if(copy($uploadedfile,$up_dir)){
$q = mysql_query("INSERT INTO attach (id_velivolo, tipo, path)
VALUES
('$id', '$tipo', '$img') ") or die(mysql_error());
if($q){
header("Location: mod_pic.php?_addpic=$id");
}
}
}
}