Mam skrypt do zapisywania załączników za pośrednictwem IMAP. Załączniki są zapisywane oprócz plików txt. Nie wyświetla się nawet błąd. Może ktoś miał podobny problem albo wie w czym jest błąd. Poniżej kod.
<?php
function parsepart($p,$i){
global $link,$msgid,$partsarray; //where to write file attachments to:
$filestore = 'pliki/';
//fetch part
$part=imap_fetchbody($link,$msgid,$i);
//if type is not text
if ($p->type!=0){
//DECODE PART
//decode if base64
//decode if quoted printable
//no need to decode binary or 8bit!
//get filename of attachment if present
$filename='';
// if there are any dparameters present in this part
if (count($p->dparameters)>0
){ foreach ($p->dparameters as $dparam){
if ((strtoupper($dparam->attribute)=='NAME') ||(strtoupper($dparam->attribute)=='FILENAME')) $filename=$dparam->value; }
}
//if no filename found
if ($filename==''){
// if there are any parameters present in this part
if (count($p->parameters)>0
){ foreach ($p->parameters as $param){
if ((strtoupper($param->attribute)=='NAME') ||(strtoupper($param->attribute)=='FILENAME')) $filename=$param->value; }
}
}
//write to disk and set partsarray variable
if ($filename!=''){
$partsarray[$i][attachment
] = array('filename'=>$filename,'binary'=>$part); $fp=fopen($filestore.$filename,"w+"); }
//end if type!=0
}
//if part is text
else if($p->type==0){
//decode text
//if QUOTED-PRINTABLE
//if base 64
//OPTIONAL PROCESSING e.g. nl2br for plain text
//if plain text
//if HTML
$partsarray[$i][text
] = array('type'=>$p->subtype,'string'=>$part); }
//if subparts... recurse into function and parse them too!
foreach ($p->parts as $pno=>$parr){
parsepart($parr,($i.'.'.($pno+1)));
}
}
return;
}
$msgid=1;
//open resource
$link=imap_open("{adres:110/pop3}INBOX", "login", "haslo");
//fetch structure of message
$s=imap_fetchstructure($link,$msgid);
//see if there are any parts
foreach ($s->parts as $partno=>$partarr){
//parse parts of email
parsepart($partarr,$partno+1);
}
}
?>
z góry dzięki za odpowiedź