prova quest'altro codice:
Codice PHP:
<?php
# ----------------------------------------------------
# ----- EMAIL PDF UPLOAD FORM
# ----- Version 2.0
# ----- Created on: 05/01/07
# ----- Designed by: American Financing
# ----- http://www.americanfinancing.net
# ----- For more scripts, please visit us at http://www.americanfinancing.net/free-scripts.cfm
# ----- Please feel free to modify this script for your own purpose.
# ----- ENJOY!!!
# ----------------------------------------------------
include("header.html");
// Receiving variables
@$Name = addslashes($_POST['Name']);
@$email = addslashes($_POST['email']);
@$upload_Name = $_FILES['upload']['name'];
@$upload_Size = $_FILES['upload']['size'];
@$upload_Temp = $_FILES['upload']['tmp_name'];
@$upload_Mime_Type = $_FILES['upload']['type'];
$upload_extension = explode('.', $upload_Name);
$upload_extension = $upload_extension[1];
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
// Validation
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Devi inserire un file valido</font></p>");
}
if( $upload_Size == 0)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Devi inserire un file valido</font></p>");
}
if( $upload_Size >2000000)
{
//delete file
unlink($upload_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'Devi inserire un file valido</font></p>");
}
if( $upload_extension != "doc" AND $upload_extension != "pdf" AND $upload_extension != "rtf" AND $upload_extension != "sims2pack" AND $upload_extension != "package" )
{
unlink($upload_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Devi inserire un file valido</font></p>");
}
$uploadFile = "uploads/".$upload_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $upload_Temp , $uploadFile);
chmod($uploadFile, 0644);
// Change This....
$upload_URL = "http://sim.altervista.org/_altervista_ht_/".$upload_Name ;
//Sending Email to form owner
# Email to Owner
$pfw_header = "From: $email";
$pfw_subject = "[FileSims]Upload";
// Change This....
$pfw_email_to = "filesims@altervista.org";
$pfw_message = "Nome: $Name\n"
. "eMail: $email\n"
. "URL: $upload_URL\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
//Sending auto respond Email to user
# Email to Owner
// Change This....
$pfw_header = "From: ";
$pfw_subject = "Confirmation Auto Responder";
$pfw_email_to = "$email";
$pfw_message = "Nome: $Name\n"
. "eMail: $email\n"
. "URL: $upload_URL";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>File Uplodato</font></p>");
include("footer.html");
?>
praticamente controlla l'estensione del file invece del mime-type