hallo zusammen
also ich habe ein "kleines" problem.
und zwar habe ich ein formular, in dem ich eine datei angeben kann, die mit dem email verschickt wird. das wird auch getan.
es kommt ein email an mit einem anhang namens "phpRH5vEq" oder ähnlichem. wenn ich die datei in "phpRH5vEq.gif", also mit der richtigen dateiendung umbenenne, dann ist das schon die richtige datei.
wie kann ich das aber machen, dass die datei mit der endung mitgeschickt wird?
so mache ich das mit dem versenden:
das formular Code:
<input name="datei" type="file">
die aufgerufene datei nach 'submit' Code:
$m->Attach( "$datei", "image/gif,image/jpeg,x-zip-compressed" ) ;
die zugehörigen libs, die in einer seperaten datei verwendet werden Code:
function Attach( $filename, $filetype = "", $disposition = "inline" )
{
// TODO : si filetype="", alors chercher dans un tablo de MT connus / extension du fichier
if( $filetype == "" )
$filetype = "application/x-unknown-content-type";
$this->aattach[] = $filename;
$this->actype[] = $filetype;
$this->adispo[] = $disposition;
}
Code:
function _build_attachement()
{
$this->xheaders["Content-Type"] = "multipart/mixed;\n boundary=\"$this->boundary\"";
$this->fullBody = "This is a multi-part message in MIME format.\n--$this->boundary\n";
$this->fullBody .= "Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n" . $this->body ."\n";
$sep= chr(13) . chr(10);
$ata= array();
$k=0;
// for each attached file, do...
for( $i=0; $i < count( $this->aattach); $i++ ) {
$filename = $this->aattach[$i];
$basename = basename($filename);
$ctype = $this->actype[$i]; // content-type
$disposition = $this->adispo[$i];
if( ! file_exists( $filename) ) {
echo "Class Mail, method attach : file $filename can't be found"; exit;
}
$subhdr= "--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding: base64\nContent-Disposition: $disposition;\n filename=\"$basename\"\n";
$ata[$k++] = $subhdr;
// non encoded line length
$linesz= filesize( $filename)+1;
$fp= fopen( $filename, 'r' );
$ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
fclose($fp);
}
$this->fullBody .= implode($sep, $ata);
}
ich hoffe das sind genügend infos...
danke!
doni