<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[problema allegare file mail]]></title><description><![CDATA[<p dir="auto">Ciao a tutti. Ho un problema nell'allegare un file ad una mail.<br />
Nel senso che la mail arriva e ha un allegato che però non ha nome nè estensione (però ha un peso), quindi non me lo fa scaricare.<br />
Mi dice:<br />
allegato senza nome</p>
<p dir="auto">posto il codice.</p>
<pre><code class="language-php">$thefile=$_FILES['thefile'];
@$thefile_name = $_FILES['thefile']['name'];
@$thefile_tmpname = $_FILES['thefile']['tmp_name'];
@$thefile_size = $_FILES['thefile']['size'];
@$thefile_type = $_FILES['thefile']['type'];
 
 
$allegato.="Content-Type: \"$thefile_type\"; name=\"$thefile_name\"\n"; 
  $allegato.="Content-Transfer-Encoding: base64\n";
  $allegato.="Content-Description: \"Allegato\"\n";
  $allegato.="Content-Disposition: attachment\n\r";  
  $fp=fopen($thefile_tmpname, "r");
  if ($fp) {
   $data = fread($fp, filesize($thefile_tmpname)); 
  }  
  $curr = base64_encode($data);
  
  $allegato .= "$curr\n\r--XX-1234DED00099A--\n";
 
 
 
$headers = "MIME-Version: 1.0\n";
 $headers .= "Content-Type: multipart/mixed; boundary=\"XX-1234DED00099A\"\n";
 $headers .= "Content-Transfer-Encoding: 7bit\n";
 $headers .= "From: $mail";
 
 $message="--XX-1234DED00099A\n";
 
 $message.="Content-Type: text/html; charset=iso-8859-1\n";
 $message.="Content-Transfer-Encoding: 7bit\n\r"; 
 $message.="&lt;html&gt;&lt;body&gt;&lt;font size=2 face=Verdana, Arial, Helvetica, sans-serif&gt;\n";
 $message.="&lt;font size=3&gt;&lt;b&gt;Dati richiedente:&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;\n";
 $message.="testo mail&lt;br&gt;\n";
 $message.="&lt;/font&gt;&lt;/body&gt;&lt;/html&gt;\n"; 
 $message.="--XX-1234DED00099A\n";
 $message.=$allegato;
 
 mail($destinatario, $oggetto, $message, $headers)
</code></pre>
]]></description><link>https://dev.connect.gt/topic/144990/problema-allegare-file-mail</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 05:37:44 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/144990.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Feb 2011 16:35:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to problema allegare file mail on Sun, 13 Feb 2011 05:43:29 GMT]]></title><description><![CDATA[<p dir="auto">mail($destinatario, $oggetto, $message, $headers, <strong>$allegato</strong>)</p>
]]></description><link>https://dev.connect.gt/post/972476</link><guid isPermaLink="true">https://dev.connect.gt/post/972476</guid><dc:creator><![CDATA[marinski]]></dc:creator><pubDate>Sun, 13 Feb 2011 05:43:29 GMT</pubDate></item></channel></rss>