codice:
<?
//user defined variables
$abpath = "/web/htdocs/www.funivie.org/home/immagini_forum/caricate"; //Absolute path to where images are uploaded. No trailing slash
$sizelim = "yes"; //Do you want size limit, yes or no
$size = "200000"; //What do you want size limited to be if there is one 200 KB
//all image types to upload
$cert1 = "image/pjpeg"; //Jpeg type 1
$cert2 = "image/jpeg"; //Jpeg type 2
$cert3 = "image/gif"; //Gif type
$cert4 = "image/ief"; //Ief type
$cert5 = "image/png"; //Png type
$cert6 = "image/tiff"; //Tiff type
$cert7 = "image/bmp"; //Bmp Type
$cert8 = "image/vnd.wap.wbmp"; //Wbmp type
$cert9 = "image/x-cmu-raster"; //Ras type
$cert10 = "image/x-x-portable-anymap"; //Pnm type
$cert11 = "image/x-portable-bitmap"; //Pbm type
$cert12 = "image/x-portable-graymap"; //Pgm type
$cert13 = "image/x-portable-pixmap"; //Ppm type
$cert14 = "image/x-rgb"; //Rgb type
$cert15 = "image/x-xbitmap"; //Xbm type
$cert16 = "image/x-xpixmap"; //Xpm type
$cert17 = "image/x-xwindowdump"; //Xwd type
$log = "";
$consenso = 1;
//begin upload 1
//checks if file exists
if ($img1_name == "") {
$log .= "Nessun file selezionato per upload 1
<a href=carica.htm>Riprova</a>";
}
// controlli contro i caratteri strani
$img1_name = str_replace("'", "", $img1_name);
$img1_name = str_replace(" ", "", $img1_name);
$img1_name = str_replace("-", "", $img1_name);
$img1_name = str_replace("'", "", $img1_name);
$img1_name = str_replace("|", "", $img1_name);
$img1_name = str_replace("?", "", $img1_name);
$img1_name = str_replace("*", "", $img1_name);
$img1_name = str_replace("[", "", $img1_name);
$img1_name = str_replace("]", "", $img1_name);
$img1_name = str_replace("(", "", $img1_name);
$img1_name = str_replace(")", "", $img1_name);
$img1_name = str_replace("!", "", $img1_name);
$img1_name = str_replace("£", "", $img1_name);
$img1_name = str_replace("$", "", $img1_name);
$img1_name = str_replace("&", "", $img1_name);
$img1_name = str_replace("/", "", $img1_name);
$img1_name = str_replace("^", "", $img1_name);
$img1_name = str_replace("è", "e", $img1_name);
$img1_name = str_replace("ò", "o", $img1_name);
$img1_name = str_replace("à", "a", $img1_name);
$img1_name = str_replace("é", "e", $img1_name);
$img1_name = str_replace("°", "", $img1_name);
$img1_name = str_replace("#", "", $img1_name);
$img1_name = str_replace("§", "", $img1_name);
$img1_name = str_replace(";", "", $img1_name);
$img1_name = str_replace(":", "", $img1_name);
$img1_name = str_replace("@", "", $img1_name);
$img1_name = str_replace("ù", "u", $img1_name);
$img1_name = str_replace("ç", "s", $img1_name);
$img1_name = str_replace("+", "", $img1_name);
$img1_name = str_replace("ì", "i", $img1_name);
// fine controlli contro i caratteri strani
if ($img1_name != "") {
//checks if file exists
if (file_exists("$abpath/$img1_name")) {
$log .= "Il file esiste già, cambiare il nome
<a href=carica.htm>Riprova</a>";
} else {
//checks if files to big
if ($sizelim == "yes") {
if ($img1_size > $size) {
$log .= "La foto è troppo grande
Una immagine cosi grande rallenterebbe moltissimo il caricamento delle pagine del forum ai visitatori
Il peso non deve superare i 300 kb
<font color=black><a href=carica.htm>Rimpiccioliscila e riprova</a></font>";
$consenso = 0;
}
}
if ($consenso != 0){
//Checks if file is an image
if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3) or ($img1_type == $cert4) or ($img1_type == $cert5) or ($img1_type == $cert6) or ($img1_type == $cert7) or ($img1_type == $cert8) or ($img1_type == $cert9) or ($img1_type == $cert10) or ($img1_type == $cert11) or ($img1_type == $cert12) or ($img1_type == $cert13) or ($img1_type == $cert14) or ($img1_type == $cert15) or ($img1_type == $cert16) or ($img1_type == $cert17)) {
@copy($img1, "$abpath/$img1_name") or $log .= "Non posso caricare il file 1
";
if (file_exists("$abpath/$img1_name")) {
$log .= "Immagine caricata con successo!
Il codice da inserire è stato copiato negli appunti, basterà quindi incollarlo nel messaggio (ctrl+V)
In alternativa copia il codice seguente nel testo del messaggio:
<p align=center><input type=button value=chiudi onclick='self.close()'></p>
<script language=javascript>
window.clipboardData.setData('Text','
');
window.opener.document.post.message.focus();
window.opener.document.post.message.value+='
'
window.setTimeout('close(self)',50);
</script>
";
}
} else {
$log .= "Il file non è immagine
<a href=carica.htm>Riprova</a>";
}
}
}
}
?>
<html>
<head>
<title>www.funivie.org :: Caricamento immagini forum</title>
</head>
<body>
<body leftmargin="5" topmargin="5">
<font color="#3399FF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<?
echo "$log";
?></font>
</p>
<body>
<html>
L'altro codice (che ho già postato sopra) va in una popup chiamata da un tasto "carica immagine" e deve consentire, tramite sfoglia, di scegliere un file da caricare dal proprio pc. Dopo premuto il tasto di conferma del form deve disattivarsi per evitare click multipli degli utenti.