Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8759533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:49:41+00:00 2026-06-13T14:49:41+00:00

I’m trying to send form with file upload , which the user entered, and

  • 0

I’m trying to send form with file upload , which the user entered, and for some reason it seems not to send the mail.
Problem is that I don’t get an error to understand where I have a mistake.

Before everything, I do not want to use any libraries to do it, I want to keep it simple.

Here is the code:

<?php  

if(isset($_POST['Submit'])){
    $strTo = "my.email@address.com";  
    $strSubject = "Purchase request from " . $_POST["formName"] . $_POST["formSurname"];  
    $strMessage = nl2br($_POST["formName"] . $_POST["formEmail"] . $_POST["formInstitute"] . $_POST["formCourse"] . $_POST["formNotes"]);  

    //*** Uniqid Session ***//  
    $strSid = md5(uniqid(time()));  

    $strHeader = "";  
    $strHeader .= "From: ".$_POST["formEmail"]."<".$_POST["formEmail"].">\nReply-To: ".$_POST["formEmail"]."";  

    $strHeader .= "MIME-Version: 1.0\n";  
    $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";  
    $strHeader .= "This is a multi-part message in MIME format.\n";  

    $strHeader .= "--".$strSid."\n";  
    $strHeader .= "Content-type: text/html; charset=utf-8\n";  
    $strHeader .= "Content-Transfer-Encoding: 7bit\n\n";  
    $strHeader .= $strMessage."\n\n";  

    //*** Attachment ***//  
    if($_FILES["fileAttach"]["name"] != "")  
    {  
        $strFilesName = $_FILES["fileAttach"]["name"];  
        $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));  
        $strHeader .= "--".$strSid."\n";  
        $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";  
        $strHeader .= "Content-Transfer-Encoding: base64\n";  
        $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";  
        $strHeader .= $strContent."\n\n";  
    }  

    $flgSend = mail($strTo,$strSubject,null,$strHeader);  // @ = No Show Error //  

    if($flgSend)  
    {  
        echo "Mail send completed.";  
    }  
    else  
    {  
        echo "Cannot send mail.";  
    }  
}
?>

and here is the form:

    <form action="#!/studentform.2ndphase" method="post" name="form1" enctype="multipart/form-data">  
        <table width="500">  
        <tr>  
            <td>שם פרטי: </td>  
            <td><input name="formName" type="text" id="name"></td>  
        </tr>  
        <tr>  
            <td>שם משפחה: </td>  
            <td><input name="formSurname" type="text" id="surname"></td>  
        </tr>  
        <tr>  
            <td>דואר אלקטרוני: </td>  
            <td><input name="formEmail" type="text"></td>  
        </tr>  
        <tr>  
            <td>מוסד אקדמי: </td>  
            <td><input name="formInstitute" type="text"></td>  
        </tr>  
            <td>מסלול: </td>  
            <td><input name="formCourse" type="text"></td>  
        </tr> 
        <tr>  
            <td>הערות</td>  
            <td><textarea name="formNotes" cols="30" rows="4" id="formNotes"></textarea></td>  
        </tr>  

        <tr>  
        <td>Attachment</td>  
        <td><input name="fileAttach" type="file"></td>  
        </tr>  
        <tr>  
        <td>&nbsp;</td>  
        <td><input type="submit" name="Submit" value="שלח"></td>  
        </tr>  
        </table>  
    </form>  

The action directs to different page, since I’m using framework based on php, this is why the link is set as #!studentform.2ndphase

Thanks for any help given.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:49:42+00:00Added an answer on June 13, 2026 at 2:49 pm

    Create a new php file, add this to it

    <?php
    phpinfo();
    ?>
    

    upload and open it in your browser, scroll down the page and check if the “sendmail_path” is empty or find the disabled functions chances are the mail function has been disabled by your host.

    or you could just run a small function to check,

    <?php
    $to      = 'you@yourdomain.com';
    $subject = 'Mail test';
    $message = 'This is a test email';
    $headers = 'From: you@yourdomain.com' . "\r\n" .
       'Reply-To: you@yourdomain.com' . "\r\n" .
       'X-Mailer: PHP/' . phpversion();
    
    mail($to, $subject, $message, $headers);
    ?> 
    

    change the “you@yourdomain.com” to your email address

    {UPDATE}

    you could use another email system to send it. or use a SMTP script

    I like: htmlMimeMail5

    <?php
    require_once("htmlMimeMail5.php");
    $mail = new htmlMimeMail5();
    $mail->setFrom("YourName <you@example.com>");
    $mail->setSubject('Test email');
    $mail->setHTML('<body background="background.gif"><b>Sample HTML</b></body>');
    $mail->send(array('sentto@example.com'));
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.