if (!isset($_GET["nome_sessione"])) {
    header("Location: login.php");
    exit;
}
$nome_sessione = $_GET["nome_sessione"];
$chiave_record = $_SESSION["chiave_record"];
$idTabella = $_SESSION["idTabella"];
$nome_file_originale = $_SESSION["nome_file_originale"];
//DEFINIZIONE CARTELLE / VALORI
$cartella_appoggio = CARTELLA_APPOGGIO_UPLOAD;
//recupero la cartella per l'upload
$cartella_upload = dimmi_cartella_upload($idTabella);
//e setto il percorso
$percorso_new = "../" . UPLOAD_FILE . "/" . $cartella_upload . "/";
crea_percorso($percorso_new);
$tipo_file = tipo_file($nome_file_originale);
//RECUPERO E SPOSTO LE IMMAGINI
//la thumb
$thumb_image_name = thumb_image_prefix . $nome_sessione . "." . $tipo_file;
$thumb_image_file = CARTELLA_APPOGGIO_UPLOAD . $thumb_image_name;
$thumb_image_name_nuovo = md5_file($thumb_image_file) . "_thumb." . $tipo_file;
$redim_image_name_nuovo = md5_file($thumb_image_file) . "." . $tipo_file;
copy($thumb_image_file, $percorso_new . $thumb_image_name_nuovo);
//e l'img a dimensione fissa
$redim_image_name = large_image_prefix . $nome_sessione . "." . $tipo_file;
if (is_file(CARTELLA_APPOGGIO_UPLOAD . $redim_image_name)) {
    $redim_image_file = CARTELLA_APPOGGIO_UPLOAD . $redim_image_name;
    copy($redim_image_file, $percorso_new . $redim_image_name_nuovo);
}
//cancello le img dalla cartella temporanea
$large_image_name = prefisso_img_originale . $nome_sessione . "." . $tipo_file;
Example #2
0
 public function campi_dett($idRecord)
 {
     $quantiFile = $this->get_nfile();
     $etichettaTbl = $this->get_etichetta();
     $cartella_upload = $this->get_cartella();
     $tipoRidim = $this->get_tipo_ridim();
     $this->tipo == "file" ? $nomeFile = "file" : ($nomeFile = "immagine");
     $etichetta = $this->campo . "_et_" . $nomeFile;
     $nomeFile = $this->campo . "_" . $nomeFile;
     //recupero i file giĆ  inseriti
     $arrFile = $this->get_file($idRecord);
     $return_tbl = "";
     for ($i = 1; $i <= $quantiFile; $i++) {
         isset($arrFile[$i - 1]) ? $valueEtichetta = $arrFile[$i - 1]["etichetta"] : ($valueEtichetta = "");
         $cartellaUp = $this->get_cartella();
         if ($this->tipo == "file") {
             $return_tbl .= "<tr><td class=\"backscuro\">" . $etichettaTbl . " " . $i . "</td><td class=\"backchiaro\">etichetta: <input type='text' name='" . $etichetta . "_" . $i . "' class='input' value='" . $valueEtichetta . "'> &nbsp;&nbsp;&nbsp;file: <input type='file' name='" . $nomeFile . "_" . $i . "' class='input'><br /><font size=1>file attuale: ";
             if (isset($arrFile[$i - 1]) and $arrFile[$i - 1] != "") {
                 $array_file = explode(":", $arrFile[$i - 1]["file"]);
                 $return_tbl .= "<a href='../" . $this->folder_upload . "/" . $cartellaUp . "/" . $array_file[1] . "' target='_blank'>" . $array_file[0] . "</a><br />";
                 $return_tbl .= "<input type='checkbox' value='si' name='" . $this->campo . "canc_" . $i . "'> cancella il file attuale";
                 $return_tbl .= "<input type='hidden' name='" . $this->campo . "idFoto_" . $i . "' value='" . $arrFile[$i - 1]["idF"] . "'>";
             } else {
                 $return_tbl .= " nessuno";
             }
             $return_tbl .= "</font></td></tr>";
         } else {
             $percorsoFile = "../" . $this->folder_upload . "/" . $cartella_upload . "/";
             $return_tbl .= "<tr><td class=\"backscuro\">" . $etichettaTbl . " " . $i . "</td><td class=\"backchiaro\">";
             if ($tipoRidim == 0 or $tipoRidim == 3) {
                 $return_tbl .= "etichetta: <input type='text' name='" . $etichetta . "_" . $i . "' class='input' value='" . $valueEtichetta . "'> &nbsp;&nbsp;&nbsp;file: <input type='file' name='" . $nomeFile . "_" . $i . "' class='input'><br /><font size=1>" . $nomeFile . " attuale: ";
                 if (isset($arrFile[$i - 1]) and $arrFile[$i - 1] != "") {
                     $array_file = explode(":", $arrFile[$i - 1]["file"]);
                     $return_tbl .= "<a href='../" . $this->folder_upload . "/" . $cartellaUp . "/" . $array_file[1] . "' target='_blank'>" . $array_file[0] . "</a><br />";
                     $return_tbl .= "<input type='checkbox' value='si' name='" . $this->campo . "cancFoto_" . $i . "'> cancella la foto attuale";
                     $return_tbl .= "<input type='hidden' name='" . $this->campo . "idFoto_" . $i . "' value='" . $arrFile[$i - 1]["idF"] . "'>";
                 } else {
                     $return_tbl .= " nessuna";
                 }
             } else {
                 if (isset($arrFile[$i - 1]) and $arrFile[$i - 1] != "") {
                     $arr_img = explode(":", $arrFile[$i - 1]["file"]);
                     $nomeFileImg = dimminomefile($arr_img[1]);
                     $tipoFile = tipo_file($arr_img[1]);
                     $nomeThumb = $nomeFileImg . "_thumb." . $tipoFile;
                     $return_tbl .= "<a href='" . $percorsoFile . $arr_img[1] . "' target='_blank'><img src='" . $percorsoFile . $nomeThumb . "' border=0></a>";
                     $return_tbl .= "<br /><input type='checkbox' value='si' name='" . $this->campo . "cancFoto_" . $i . "'> cancella la foto attuale";
                     $return_tbl .= "<input type='hidden' name='" . $this->campo . "idFoto_" . $i . "' value='" . $arrFile[$i - 1]["idF"] . "'>";
                 } else {
                     $return_tbl .= "<a href=\"#\" onClick=\"apri_upload(" . $idRecord . ", " . $this->idTabella . ");\">carica un'immagine</a>";
                 }
             }
             print "</td></tr>";
         }
     }
     return $return_tbl;
 }
Example #3
0
function icona_file($filename)
{
    $tipofile = tipo_file($filename);
    switch (strtolower($tipofile)) {
        case "doc":
            $icona = "doc.jpg";
            break;
        case "pdf":
            $icona = "pdf.jpg";
            break;
        case "txt":
            $icona = "txt.jpg";
            break;
        case "xls":
            $icona = "xls.jpg";
            break;
        case "zip":
            $icona = "zip.jpg";
            break;
        case "jpg":
            $icona = "img.jpg";
            break;
        case "gif":
            $icona = "img.jpg";
            break;
        case "swf":
            $icona = "filmato.jpg";
            break;
        case "flv":
            $icona = "filmato.jpg";
            break;
        case "mp4":
            $icona = "filmato.jpg";
            break;
        default:
            $icona = "ic_clips.jpg";
            break;
    }
    return $icona;
}
function upload()
{
    $uploaddir = '../upload/tmp/';
    $file = $uploaddir . basename($_FILES['uploadfile']['name']);
    if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
        //inserisco il timestamp all'immagine
        $filename = dimminomefile(basename($_FILES['uploadfile']['name']));
        $tipo_file = tipo_file(basename($_FILES['uploadfile']['name']));
        $file_rinominato = $filename . "_" . strtotime(date('Y-m-d H:i:s')) . "." . $tipo_file;
        rename($file, $uploaddir . $file_rinominato);
        echo "success:" . $file_rinominato;
    } else {
        echo "error";
    }
}
Example #5
0
    ?>
"/>
				<input type="hidden" name="h" id="h" value="<?php 
    print $h_value;
    ?>
"/>
				<input style="font-size:16px;" type="submit" name="upload_thumbnail" value="Salva immagine ridimensionata" id="save_thumb" />
			</form>
			</div>
	</div>	
	<?php 
}
if (isset($_POST["nStep"]) && $_POST["nStep"] == 3 && (isset($_POST["imgBig"]) || isset($_POST["imgBigSALTATA"]))) {
    $immagine_caricata = $_POST["imgBig"];
    $filename = dimminomefile($immagine_caricata);
    $tipo_file = tipo_file($immagine_caricata);
    if (!isset($_POST["imgBigSALTATA"])) {
        $numero_STEP = 4;
        $immagineRid = $upload_dir . large_image_prefix . $_SESSION['random_key'] . "." . $tipo_file;
    } else {
        $numero_STEP = 3;
    }
    $immagineThumb = $upload_dir . thumb_image_prefix . $_SESSION['random_key'] . "." . $tipo_file;
    //	$immagineRid = $upload_dir . large_image_prefix . $_SESSION['random_key'] . "." . $tipo_file;
    ?>
	<h2><u>Step <?php 
    print $numero_STEP;
    ?>
</u>: Conferma ridimensionamento</h2>
	<form method="post" action="upload_image_save.php?nome_sessione=<?php 
    print $_SESSION['random_key'];