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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:35:32+00:00 2026-06-01T08:35:32+00:00

I writte this code to send multiple attachments: $tablica_plikow=$_FILES[file]; //array of files if(!empty($tablica_plikow[‘name’])){///if attachment

  • 0

I writte this code to send multiple attachments:

    $tablica_plikow=$_FILES["file"]; //array of files
if(!empty($tablica_plikow['name'])){///if attachment 
          $uid = md5(uniqid(time()));

    $header =  "From: od\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";

    $header .= "--".$uid."\r\n";
    $header .= "Content-type:text/html; charset=iso-8859-2\r\n";
    $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $header .=win2iso( $_POST['tresc'])."\r\n\r\n\r\n\r\n\r\n\r\n";///message
    $header .= "--".$uid."\r\n";

    for($i=0; $i<count($tablica_plikow['name']); $i++){

    if ($tablica_plikow["error"][$i] > 0)
    { $komunikat = "<img src=\"img_panel/bttn_error.gif\">"."Return Code: " . $tablica_plikow["error"][$i] ;


    }
    if (file_exists("zalacznik/" . $tablica_plikow["name"][$i]))
      {

      $komunikat = "<img src=\"img_panel/bttn_error.gif\">"."Return Code: " . $tablica_plikow["name"][$i]. " already exists. " ;

      }
    else
      {
        if(is_uploaded_file($tablica_plikow["tmp_name"][$i])) { 
    move_uploaded_file($tablica_plikow["tmp_name"][$i],
    "zalacznik/" . $tablica_plikow["name"][$i]);
    $komunikat = "<img src=\"img_panel/bttn_info.gif\">" . "zalacznik/" . $tablica_plikow["name"][$i];

    $target_path="zalacznik/" . $tablica_plikow["name"][$i];
    $file = "zalacznik/".$tablica_plikow["name"][$i];
    $file_size = filesize($file);
    $handle = fopen($file, "rb");
    $content = fread($handle, $file_size);
    fclose($handle);
    $content = chunk_split(base64_encode($content));
    $name = basename($file);
    $header .= "Content-Type: ".$tablica_plikow["type"][$i]." name=\"".$tablica_plikow["name"][$i]."\"\r\n"; // use different content types here
    $header .= "Content-Transfer-Encoding: base64\n\r".$content."\r\n\r\n";;
    $header .= "Content-Disposition: attachment; filename=\"".$tablica_plikow["name"][$i]."\"\r\n\r\n";
   // $header .= $content."\r\n\r\n";
    $header .= "--".$uid."-- \r\n";

            }
        }
    }
     if (mail("mail@moj.com", $_POST['tytul'], "", $header)) {

         $komunikat = "<img src=\"img_panel/bttn_info.gif\">mail send";


    } else {
      $komunikat = "<img src=\"img_panel/bttn_error.gif\">error";

      }

But when I send an email with two or more attachments, receive only one file.This file is a concatenation of all attachments. But the first part of the file is the first attachment, and other parts are just hashmap other files.

  • 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-01T08:35:33+00:00Added an answer on June 1, 2026 at 8:35 am

    I advice you use standard and tested mailing lib such as phpMail

    It has been discussed here before Please see regarding email with attachment in php

    Thanks

    🙂

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

Sidebar

Related Questions

I've written this code to try and send a url as a post value
I have this code written in .NET 4.0 using VS2010 Ultimate Beta 2: smtpClient.Send(mailMsg);
I am using below code to send a byte array to a site. Why
Possible Duplicate: Send email using System.Net.Mail through gmail. (C#) I am using this code
I written this code: #include <stdio.h> #include <pthread.h> void* cuoco(void* arg) { fprintf(stderr,Inizio codice
i write this code in main.java ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); try{ HttpClient httpclient
I have written this code to join ArrayList elements: Can it be optimized more?
would someone please write this code: this.Loaded += (s, e) => this.loaded = true;
How can I write this code more cleanly/concisely? /// <summary> /// Creates a set
I have written this code to convert string in such format 0(532) 222 22

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.