Ciao ragazzi, ho uno script PHP a disposizione che funziona male, ovvero ho inserito un controllo sulle estensioni per evitare disguidi, ma da quando l'ho messo se l'estensione è corretta e anche quando non lo è non mi viene restituito alcun messaggio...
La funzione che ho messo è:
Codice PHP:
if (($HTTP_POST_FILES['upfile']['type']=="image/gif") || ($HTTP_POST_FILES['upfile']['type']=="image/bmp")|| ($HTTP_POST_FILES['upfile']['type']=="image/png") || ($HTTP_POST_FILES['upfile']['type']=="image/psd") || ($HTTP_POST_FILES['upfile']['type']=="file/zip") || ($HTTP_POST_FILES['upfile']['type']=="file/rar") || ($HTTP_POST_FILES['upfile']['type']=="image/jpg")) {
Lo script è:
Codice PHP:
<?php
$file_name = $_FILES['upfile']['name'];
$file_temp = $_FILES['upfile']['tmp_name'];
$file_type = $_FILES['upfile']['type'];
$file_size = $_FILES['upfile']['size'];
$upload_dir = "altervista_ht_";
$righe = file("db.txt");
$righe[count($righe)-1] = explode("|",$righe[count($righe)-1]);
$fgt = $righe[count($righe)-2][0]+1;
unset($righe);
if (($HTTP_POST_FILES['upfile']['type']=="image/gif") || ($HTTP_POST_FILES['upfile']['type']=="image/bmp")|| ($HTTP_POST_FILES['upfile']['type']=="image/png") || ($HTTP_POST_FILES['upfile']['type']=="image/psd") || ($HTTP_POST_FILES['upfile']['type']=="file/zip") || ($HTTP_POST_FILES['upfile']['type']=="file/rar") || ($HTTP_POST_FILES['upfile']['type']=="image/jpg")) {
if ( !is_uploaded_file($_FILES["upfile"]["tmp_name"]) )
{
echo "File non inserito (".$_FILES["upfile"]["error"].")";
}
else
{
$ext = explode (".", $file_name);
$num=1;
while (file_exists($upload_dir."/".$file_name)) {
$nome_file=explode(".",$file_name);
if (count($nome_file)>1) {
$file_name="";
for($i=0;$i<count($nome_file)-1;$i++) {
$file_name.=$nome_file[$i];
if ($i<count($nome_file)-2)
$file_name.=".";
}
$file_name.=$num.".".$file_name[count($nome_file)-1];
}
else
$file_name=$nome_file[0].$num;
$num++;
}
$st="$fgt|$file_name|\n";
$op_db = fopen("db.txt","a");
$fpx = fputs($op_db,$st);
fclose($op_db);
echo "File inserito con successo!<br /><br /> <b>Link diretto:</b> <input type='text' value='http://uploadyourfile.altervista.org/altervista_ht_/$file_name' size='60'/><br /> ";
copy ($file_temp,"$upload_dir/$file_name");
}
}
else { echo "Estensione diversa da quelle disponibili"; exit; }
?>