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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:32:22+00:00 2026-06-12T19:32:22+00:00

i have a small issue. i had upload a screen shot of a email

  • 0

i have a small issue. i had upload a screen shot of a email that has an attachment sent by using php.but in the attachment name there is the directory name as “upload./” i want to remove that part. how can i do that?

Thank you.enter image description here

$message = $mes;
                echo $message;

                //echo $message;
                $subject = $coursetitle;
                $headers .= 'Cc: gayani@amdt.lk' . "\r\n";

                ini_set("SMTP", "mail.amdt.lk");
                ini_set("sendmail_from", "info@amdt.lk");

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

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

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

                // preparing attachments




                        for($x=0;$x<count($files);$x++){
                            $file = fopen($dir.$files[$x],"rb");
                            $data = fread($file,filesize($dir.$files[$x]));
                            fclose($file);
                            $data = chunk_split(base64_encode($data));
                            $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$dir.$files[$x]\"\n" . 
                            "Content-Disposition: attachment;\n" . " filename=\"$dir.$files[$x]\"\n" . 
                            "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
                            $message .= "--{$mime_boundary}\n";
                        }



                // send
                //echo $message;
               $ok = mail($to, $subject, $message, $headers);
               if ($ok) {
                 echo "<p>mail sent to $to!</p>";
                } else {
                 echo "<p>mail could not be sent!</p>";
              }
  • 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-12T19:32:23+00:00Added an answer on June 12, 2026 at 7:32 pm

    You’re doing it yourself…

    "Content-Disposition: attachment;\n" . " filename=\"$dir.$files[$x]\"\n" 
                                                        ^^^^
    

    that’s the filename as it should appear in the client browser… it has nothing to do with where the file is on your server, or what its name is on your server. That’s purely for the remote user’s information.

    In the greater scheme of things… don’t build your own mime messages, or use mail(). Mime is painful to get right, when there’s perfectly good libraries like PHPMailer and Swiftmailer that do all of that for you with far less code.

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

Sidebar

Related Questions

I have a small issue with a method that should save the text contained
I am just new to programming in Unix and have a small issue that
I'm building a MonoTouch iPhone app, but have come up with a small issue.
I have a small issue, I had my SIP client working, and I changed
I have a small app that allows the user to draw on the screen
I have a PHP SOAP server (using nuSOAP) that I consume with a C#-based
I have a small issue with sessions. I have built a small shopping cart-esque
I have a small issue(for lack of a better word) with MySQL db. I
i have a small issue which my text field insist to inhert the CSS
can anyone help, i have a small issue, i have an interface and also

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.