Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z załącznikiem *.xml
new_user
post
Post #1





Grupa: Zarejestrowani
Postów: 66
Pomógł: 0
Dołączył: 20.02.2007

Ostrzeżenie: (0%)
-----


Witam

Mam zrobony jeden skryp do generowania pliku xml z bazy postgres.
Składnia wygenerowanego gotowego i zapisanego na serwerze pliku wygląda podobnie do tej ponizej:

  1. <?xml version="1.0" encoding="ISO-8859-2" ?>
  2. <data>
  3.      <header>
  4.            <column name="1" type="int4" />
  5.            <column name="2" type="text" />
  6.            <column name="3" type="text" />
  7.            <column name="4" type="text" />
  8.            <column name="5" type="text" />
  9.            <column name="6" type="text" />
  10.            <column name="7" type="text" />
  11.  
  12.      </header>
  13.      <records>
  14.            <row>
  15.                  <column name="1">1</column>
  16.                  <column name="2">2</column>
  17.                  <column name="3">2</column>
  18.                  <column name="4">4</column>
  19.                  <column name="5">5</column>
  20.                  <column name="6">6</column>
  21.                  <column name="7">7</column>
  22.            </row>
  23.      </records>
  24. </data>


drugi skrypt wysyłający wysyła ten plik na wskazany adres email. Wszystko działa dobrze tylko jedno jest nie tak.
Plik który na serwerze jest poprawnym xml (kod powyżej) po przesłaniu i odebraniu a następnie otworzeniu odebranego pliku xml ma składnię podobna do ponizszej:

  1. <?xml version=\"1.0\" encoding=\"ISO-8859-2\" ?>
  2. <data>
  3.      <header>
  4.            <column name=\"1\" type=\"int4\" />
  5.            <column name=\"2\" type=\"text\" />
  6.            <column name=\"3\" type=\"text\" />
  7.            <column name=\"4\" type=\"text\" />
  8.            <column name=\"5\" type=\"text\" />
  9.            <column name=\"6\" type=\"text\" />
  10.            <column name=\"7\" type=\"text\" />
  11.  
  12.      </header>
  13.      <records>
  14.            <row>
  15.                  <column name=\"1\">1</column>
  16.                  <column name=\"2\">2</column>
  17.                  <column name=\"3\">2</column>
  18.                  <column name=\"4\">4</column>
  19.                  <column name=\"5\">5</column>
  20.                  <column name=\"6\">6</column>
  21.                  <column name=\"7\">7</column>
  22.            </row>
  23.      </records>
  24. </data>


Skryt wysyłający wygląda tak:

  1. <?php 
  2. $boundary = "-->===_53414723_===<---->>4221==_"; 
  3.  
  4. $header = "From: from\n"; 
  5. $header = $header . "Reply-To: replyto\n"; 
  6. $header = $header . "X-Mailer: PHP\n"; 
  7. $header = $header . "X-Sender: from\n"; 
  8. $header = $header . "MIME-version: 1.0\n"; 
  9. $header = $header . "Content-type: multipart/mixed; "; 
  10. $header = $header . "boundary=\"$boundary\"\n"; 
  11. $header = $header . "Content-transfer-encoding: 8bit\n"; 
  12. $header = $header . "X-attachments: plik.xml;\n\n"; 
  13.  
  14. $mesg = "--" . $boundary . "\n"; 
  15. $mesg = $mesg . "Content-Type: text/plain; charset=\"iso-8859-2\"\n\n"; 
  16. $mesg = $mesg . $message . "\n"; 
  17. $mesg = $mesg . "--" . $boundary . "\n"; 
  18. $mesg = $mesg . "Content-type: text/xml; name=\"plik.xml";&#092;n";  
  19. $mesg = $mesg . "Content-Transfer-Encoding: base64\n"; 
  20. $mesg = $mesg . "Content-disposition: attachment; filename= \"plik.xml\"\n\n"; 
  21. $mesg = $mesg . encoding($filename) . "\n";
  22. $mesg = $mesg . "--" . $boundary . "-- \n";
  23.  
  24. function encoding($file) { 
  25. if (is_readable($file)) { 
  26.  $fd = fopen($file, "r"); 
  27.  $plik = fread($fd, filesize($file)); 
  28.  $encoded = chunk_split(base64_encode($plik)); 
  29.  fclose($fd);  
  30. } 
  31. return $encoded; 
  32. } 
  33.  
  34. mail("mail@serwer.pl", "TEMAT MAILA", $mesg, $head);
  35. ?>


Co zrobić żeby mail plik był wysłany w formacie takim jak jest na serwerze a nie przetworzony i przed " jest wstawione \.

Ten post edytował new_user 27.03.2008, 09:01:20
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.12.2025 - 13:41