certo
Codice PHP:
if($_POST['action'] == "carica"){
$new_name = "1";
if($new_name != ''){
// DA QUI INIZIO PER CARICARE L'IMMAGINE
if(!isset($_POST['Submit'])){
header("Location: index.php");
}else{
include_once 'config.php';
//faccio l'upload dell'img
include_once 'include/upload.class.php';
if(!isset($_FILES)) $_FILES = $HTTP_POST_FILES;
if(!isset($_SERVER)) $_FILES = $HTTP_POST_VARS;
$up = new FileUpload(TMP_DIR);
$up->RenameFile($_POST['new_name']);
$up->Upload($_FILES['file']);
//adesso ridimensiono l'img a 400 x 400
include_once 'include/image.class.php';
$img = new Image(TMP_DIR . '/' . $up->filename);
//creo l'immagine sorgente
$result = $img->CreateSourceImage();
//se il tipo di immagine supportato
//salvo 2 file:
//uno con l'img grande e uno con l'img piccola
//nelle rispettive directory
if($result){
//salvo l'immagine con altezza 400 lasciandola proporzionata
$img->SaveProportionateImage(IMAGE_DIR . '/' . $up->filename, IMAGE_QUALITY, IMAGE_HEIGHT, IMAGE_WIDTH);
//salvo l'immagine con altezza 75 lasciandola proporzionata
$img->SaveProportionateImage(THUMB_DIR . '/' . $up->filename, THUMB_QUALITY, THUMB_HEIGHT, THUMB_WIDTH);
//libero la memoria cancellando l'immagine sorgente
$img->Free();
}
//se il tipo di img non supportata
//o se il file uploadato nn un immagine
else
echo 'Immagine non valida
';
//In ogni caso cancello il file uploadato nella cartella ./tmp
$insertSQL = "INSERT INTO `xml` ( `id` , `path` , `description` , `thumbnail` , `link` , `id_gallery` ) VALUES (NULL , '$nome.jpg', '$descrizione', '$nome.jpg', '$link', '$cartella');";
mysql_query($insertSQL, $connessione) or die(mysql_error());
generaxml($connessione,$campo,'../images/'.$cartella.'/xml_'.$cartella.'.xml',$cartella);
$up->DeleteFile();
$stampa ='<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body onload="top.location.reload(true);self.close();">
</body>
</html>';
echo $stampa;
}
}else{
}
}
grazie ancora