Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
function cancella_file($tabella, $campo_img, $campo_id, $id_record, $md5file, $percorso_file)
{
    $query_controllo = "select " . $campo_img . " from " . $tabella . " where " . $campo_img . " LIKE '%" . $md5file . "%' and " . $campo_id . " <> " . $id_record;
    $res_controllo = makequery($query_controllo);
    $num_controllo = mysqli_num_rows($res_controllo);
    if ($num_controllo == 0) {
        $filename = $percorso_file . "/" . $md5file;
        if (file_exists($filename)) {
            unlink($filename);
        }
        //Devo controllare se c'è la thumb, e nel caso la cancella
        //nome dell'img md5, senza estensione
        $nome_file = dimminomefile($percorso_file . "/" . $md5file);
        $nome_file_thumb = $nome_file . "_thumb.jpg";
        if (file_exists($percorso_file . "/" . $nome_file_thumb)) {
            unlink($percorso_file . "/" . $nome_file_thumb);
        }
    }
}
Exemplo n.º 3
0
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";
    }
}
Exemplo n.º 4
0
    print $w_value;
    ?>
"/>
				<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