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 6841439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:58:00+00:00 2026-05-26T23:58:00+00:00

I have a form for that a user fills out and submits. Once submitted

  • 0

I have a form for that a user fills out and submits. Once submitted The form needs to create a doc from the input, attach the doc to an email with the mail() function and email it to the person I specify.

Currently I am creating the doc file this way:

HEADER("Content-Type: application/vnd.ms-word; name='word'"); 
HEADER("Content-type: application/octet-stream"); 
HEADER("Content-Disposition: attachment; filename=filename_here.doc"); 
HEADER("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
HEADER("Pragma: no-cache"); 
HEADER("Expires: 0"); 

ECHO $header."\n".$body; 
EXIT;

Obviously this outputs the document. I want to attach it to an email since I don’t want the user to get the document. The user will be redirected to a confirmation or error page depending on the situation.

Thanks!

————– EDIT —————–

I have the script sending an email with an attachment now. However, the attachment is only 3k is size. This is the script I’m using to attach the data and send the email. Its the same script I use when a user provides the file. I changed the script from reading in the data from a file to base ecode the “body” directly.

$headers = "From: fromperson@email.com";

    // Generate a boundary string
    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

    // Add the headers for a file attachment
    $headers .= "\nMIME-Version: 1.0\n" .
    "Content-Type: multipart/mixed;\n" .
    " boundary=\"{$mime_boundary}\"";

    // Add a multipart boundary above the plain message
    $message = "This is a multi-part message in MIME format.\n\n" .
    "--{$mime_boundary}\n" .
    "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
    "Content-Transfer-Encoding: 7bit\n\n" .
    $content . "\n\n";

    // Base64 encode the file data
    $data = chunk_split(base64_encode($body));

    // Add file attachment to the message
    $message .= "--{$mime_boundary}\n" .
    "Content-Type: application/ms-word;\n" .
    " name=\"testfile.doc\"\n" .
    "Content-Disposition: attachment;\n" .
    " filename=\"testfile.doc\"\n" .
    "Content-Transfer-Encoding: base64\n\n" .
    $data . "\n\n" .
    "--{$mime_boundary}--\n";

    // Send the message
    $ok = @mail('toperson@email.com', 'test file', $message, $headers);
    if ($ok) 
    {
        echo 'yes';
    } else 
    {
        echo 'no';
    }

I’m not seeing why the file is only 3k.

  • 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-05-26T23:58:01+00:00Added an answer on May 26, 2026 at 11:58 pm

    The script that was added as the edit is a functional script. The blank file was an issue on my end (user error from lack of sleep). For those that come across this question: The script after the edit is a working script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a form that the user fills out, when submitted an new
I have a form that a user fills out, which submits information to my
I have a form that I'm submitting with AJAX. A user fills out the
So I have a form that accepts some input from a user that may
I have a form that a user fills out prior to reaching the PayPal
Here's what I want to do. I have a form that the user fills
I have a form that and after the user fills in this form, I
I have a form that the user submits and returns a result, but it
I have a quotation form where the user fills out the boxes, clicks submit
Afternoon All, I have a web form that i wish my user to fill

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.