Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Problem sa attachmentom

[es] :: PHP :: Problem sa attachmentom

[ Pregleda: 2020 | Odgovora: 6 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

manix
IDD Lab
Arilje

Član broj: 9936
Poruke: 482
*.adsl.verat.net.

Sajt: www.lendovisanje.com


Profil

icon Problem sa attachmentom17.01.2008. u 02:59 - pre 197 meseci
Odamah da kazem da sam pretrazio forum i da mi nije jasno gde je grska!!!

Dobijam sve sem attachmenta - tacan zaiv fajla, -----Inline Attachment Follows----- ali slike nigde samo objkat scr
Iz attachment ne dobijam 'filename' a 'name', 'type' dobijam

evo koda koji testiram
Code:
<?php
function formaAtt($attashment=""){
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data" name="posalji">
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input name="attachment" type="file" /></td>
    <td><input name="potvrdi" type="submit" value="potvrdi" /></td>
  </tr>
</table>
</form>
<?php
}

function slanjeEmaila($attachment){

    $emailTelo        = "Uz ovu poruku bi trebalo da ima attachment";
    $emailZa          = "[email protected]";
    $emailOd          = "[email protected]";
    $emailNaslov    = "e-Mali system v3.0 by IDD Lab";
    $emailPredmet    = "Proba slanja emaila v3";

    $emailHeader  = "From: $emailNaslov <$emailOd>\r\nReply-To: $emailOd\r\n";
    $emailHeader .= "MIME-Version: 1.0\r\n";
    $emailHeader .= "Content-Type: multipart/mixed; boundary=\"MIME_BOUNDRY\"\r\n";
    $emailPoruka  = "--MIME_BOUNDRY\r\n";
    $emailPoruka .= "Content-type: text/html; charset=utf-8\r\n";
    $emailPoruka .= "\r\n";
    $emailPoruka .= $emailTelo;
    $emailPoruka .= "\r\n";

    $filename     = $attachment['filename'];
    $name             = $attachment['name'];
        $type             = $attachment['type'];

    $file_url = 'http://www.iddlab.com/garman/tmp/' . $filename;
    $fp = fopen($file_url,"rb");
    $attachment = fread($fp, filesize($file_url));
    $attachment = chunk_split(base64_encode($attachment));

    $emailPoruka .= "--MIME_BOUNDRY\r\n";
    $emailPoruka .= "Content-Type: $type ; name=\"$name\"\r\n";
    $emailPoruka .= "Content-disposition: attachment\r\n";
    $emailPoruka .= "Content-Transfer-Encoding: base64\r\n";
    $emailPoruka .= "\r\n";
    $emailPoruka .= "$attachment\r\n";
    $emailPoruka .= "\r\n";
    $emailPoruka .= "--MIME_BOUNDRY--\r\n";

        echo "filename: ".$filename . '<br/>';
        echo "name: ".$name . '<br/>';
        echo "file type: "    .$type. '<br/>';
        echo "file url: ".$file_url. '<br/>';
        
    mail($emailZa, $emailPredmet, $emailPoruka, $emailHeader);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Attachmenta</title>
</head>

<body>
<?php
if(!isset($_POST['potvrdi'])){
        formaAtt();
}else{
        $attachment=$_FILES["attachment"];
        $putanja="tmp/". $_FILES["attachment"]["name"];
        move_uploaded_file($_FILES["attachment"]["tmp_name"], $putanja);
        slanjeEmaila($attachment);
}
?>
</body>
</html>

Sto se tice putanje $file_url = 'http://www.iddlab.com/garman/tmp/' - stavljao sam i $file_url = 'tmp/'

Ako neko meze neka pomogne, oci mi ispadose...
Hvala unapred
 
Odgovor na temu

Jbyn4e

Član broj: 422
Poruke: 6049
*.yunix.co.yu.



+257 Profil

icon Re: Problem sa attachmentom17.01.2008. u 07:59 - pre 197 meseci
Baci pogled:
http://www.sitepoint.com/print/advanced-email-php
A i nije mi jasno otkud ti ovo:
Citat:

MIME_BOUNDRY

boundry???
Kad sve ostalo zakaže, pročitaj uputstvo...
 
Odgovor na temu

manix
IDD Lab
Arilje

Član broj: 9936
Poruke: 482
*.adsl.verat.net.

Sajt: www.lendovisanje.com


Profil

icon Re: Problem sa attachmentom17.01.2008. u 09:31 - pre 197 meseci
o, pardon ovo nedostaje na pocetku koda ali ni sa time ne radi...
Ali slucajno ga nisam stavio ovde u kodu a inace kod mene stoji.
Inace skript sam nasao na netu ...

Code:

$neki_rand = md5(time()); 
$mime_boundary = "==Multipart_Boundary_x{$neki_rand}x"; 

define ("MIME_BOUNDRY", $mime_boundary);
 
Odgovor na temu

manix
IDD Lab
Arilje

Član broj: 9936
Poruke: 482
*.adsl.verat.net.

Sajt: www.lendovisanje.com


Profil

icon Re: Problem sa attachmentom17.01.2008. u 10:45 - pre 197 meseci


e sada sam probao ovo sa ovog linka i salje att smo sto mi tamo umesto slike stignu brojke
 
Odgovor na temu

manix
IDD Lab
Arilje

Član broj: 9936
Poruke: 482
*.adsl.verat.net.

Sajt: www.lendovisanje.com


Profil

icon Re: Problem sa attachmentom17.01.2008. u 11:52 - pre 197 meseci
Problem resen

Code:
<?php 
function formaAtt($attashment=""){
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data" name="posalji">
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input name="attachment" type="file" /></td>
    <td><input name="potvrdi" type="submit" value="potvrdi" /></td>
  </tr>
</table>
</form>
<?php
}

function slanjeEmaila($attachment){
            
    $neki_rand = md5(time()); 
    $mime_boundary = "==Multipart_Boundary_x{$neki_rand}x"; 
    $emailTelo            = "Uz ovu poruku bi trebalo da ima attachment";
    $emailZa                  = "[email protected]";
    $emailOd              = "[email protected]";
    $emailNaslov            = "e-Mali system v3.0 by IDD Lab";
    $emailPredmet    = "Proba slanja emaila v3";

    // Var. uploadovanog fajla
    $attachment            = $_FILES['attachment']['tmp_name']; 
    $attachment_type  = $_FILES['attachment']['type']; 
    $attachment_name = $_FILES['attachment']['name'];

    // Citanje fajla koji ce biti poslat ('rb' = read binary) 
    if (is_uploaded_file($attachment)) { 
     $file = fopen($attachment,'rb'); 
     $data = fread($file,filesize($attachment)); 
     fclose($file);
        
     // Generisanje boundary string-a
     $neki_rand = md5(time()); 
     $mime_boundary = "==Multipart_Boundary_x{$neki_rand}x"; 
                
     // Headers 
     $emailHeaders  = "From: $emailNaslov <$emailOd>\r\nReply-To: $emailOd\r\n";
     $emailHeaders .= "MIME-Version: 1.0\r\n";
     $emailHeaders .= "Content-Type: multipart/mixed; boundary=\"{$mime_boundary}\"\r\n";
                
     $emailPoruka  = "--{$mime_boundary}\r\n";
     $emailPoruka .= "Content-type: text/html; charset=utf-8\r\n";
     $emailPoruka .= "\r\n";
     $emailPoruka .=  $emailTelo;
     $emailPoruka .= "\r\n";

     // Base64 encodiranje podataka fajla
     $data = chunk_split(base64_encode($data));
                
     // Dodavanje attachment-a u emailPoruka 
     $emailPoruka .= "--{$mime_boundary}\r\n";
     $emailPoruka .= "Content-Type: $attachment_type ; name=\"$attachment_name\"\r\n";
     $emailPoruka .= "Content-disposition: attachment\r\n";
     $emailPoruka .= "Content-Transfer-Encoding: base64\r\n";
     $emailPoruka .= "\r\n";
     $emailPoruka .= "$data\r\n";
     $emailPoruka .= "\r\n";
     $emailPoruka .= "--{$mime_boundary}--\r\n";
    }

    mail($emailZa, $emailPredmet, $emailPoruka, $emailHeaders);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Attachmenta</title>
</head>

<body>
<?php
if(!isset($_POST['potvrdi'])){
   formaAtt();
}else{
   $attachment=$_FILES["attachment"];
   $putanja=$_FILES["attachment"]["name"];
   move_uploaded_file($_FILES["attachment"]["tmp_name"], $putanja);
   slanjeEmaila($attachment);
}
?>
</body>
</html>


[Ovu poruku je menjao manix dana 17.01.2008. u 13:02 GMT+1]
 
Odgovor na temu

manix
IDD Lab
Arilje

Član broj: 9936
Poruke: 482
*.adsl.verat.net.

Sajt: www.lendovisanje.com


Profil

icon Re: Problem sa attachmentom17.01.2008. u 12:51 - pre 197 meseci
Jbyn4e ovo sto si mi dao je ipak dosta pomoglo. HVALA!
 
Odgovor na temu

Jbyn4e

Član broj: 422
Poruke: 6049
*.ptt.yu.



+257 Profil

icon Re: Problem sa attachmentom17.01.2008. u 15:59 - pre 197 meseci
Molim i drugi put. Drago mi je kad neko napravi resenje a ne trazi gotov kod, kakvih ima jako puno, nazalost.
Kad sve ostalo zakaže, pročitaj uputstvo...
 
Odgovor na temu

[es] :: PHP :: Problem sa attachmentom

[ Pregleda: 2020 | Odgovora: 6 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.