Form submit file attach

if( isset($_POST['myFile']) ){

    $attachname8=$_FILES['myFile']['name'];
    $attachment8='';

    $output_dir="report/";
    //Filter the file types , if you want.

    if(!empty($attachname8))
    {
        if ($_FILES["myFile"]["name"] > 0)
        {
              echo "Error: " . $_FILES["myFile"]["error"] . "<br>";
        }
        else
        {
             //move the uploaded file to uploads folder;
             move_uploaded_file($_FILES["myFile"] ["tmp_name"],$output_dir.$_FILES["myFile"]["name"]);
             $attachment8="report/".$_FILES["myFile"]["name"];

        }
    }
}

Leave a Comment