0

I am using PHP to upload files to my web site and then sending them to my mail address. Everything is working fine, except that, when somebody tries to upload a zip archive containing .js files (or .bat, .cmd and similar), Google blocks them, because it considers them potentially dangerous.

I'd like to display an error message, telling the user that his zip contains files not uploadable (not permitted extensions). And here is my question. How can I browse inside the uploaded file (even in subfolders!) in order to spot prohibited extensions?

Here is my PHP code (just the beginning):

if($_POST && isset($_FILES['my_file']))
{

    if ($_REQUEST['pippo'] != "abracadabra")
        die("Errore: password non corretta!");


    $sender = preg_replace('/\s+/', '.', $_REQUEST['name']);


    $from_email = $sender.'@example.com'; //sender email
    $recipient_email = 'giancarloperlo@gmail.com'; //recipient email
    $subject = $_FILES['my_file']['name']; //subject of email
    $message = 'Caricamento file da '.$_REQUEST['name']; //message body

    //get file details we need
    $file_tmp_name    = $_FILES['my_file']['tmp_name'];
    $file_name        = $_FILES['my_file']['name'];
    $file_size        = $_FILES['my_file']['size'];
    $file_type        = $_FILES['my_file']['type'];
    $file_error       = $_FILES['my_file']['error'];

    //$user_email = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);

    if($file_error>0)
    {
        die('upload error');
    }
    //read from the uploaded file & base64_encode content for the mail
    $handle = fopen($file_tmp_name, "r");
    $content = fread($handle, $file_size);
    fclose($handle);
    ....

Thanks to everybody for kind attenion and help!

0 Answers0