Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]File open - łączenie stringa i podanie zmiennej jako parametr.
cykcykacz
post
Post #1





Grupa: Zarejestrowani
Postów: 550
Pomógł: 9
Dołączył: 29.05.2009
Skąd: Ostrów Wielkopolski

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


Hej,
mam problem przy funkcji fopen jako paramter nalerzy podać nazwę pliku.
Chcę złączyć dwa stringi, i podać jako zmienną do funkcji fopen i tutaj pojawia się problem:
Kod
Warning: fopen(119</td>myText.txt): failed to open stream: Invalid argument in C:\wamp\www...


A robię to w ten sposób:
  1. $id=1;
  2. $file = 'myText.txt';
  3.  
  4. $id = $id.$file;
  5. //explode($delimiter, $id);
  6. $content = "<PMTags1.0 win>".PHP_EOL;
  7. $content .= PHP_EOL;
  8. $content .= "<@win:><\<>win>". $category .PHP_EOL;
  9. $content .= "<@tekst:><\<>tekst><$>";
  10. $content .= $result2;
  11. $content .= $gcid;
  12. utf8_encode($content);
  13. echo $content;
  14. //Stworzenie pliku
  15. $fp = fopen($id,"wb");
  16.  
  17. fwrite($fp,$content);
  18. fwrite($fp, pack("CCC",0xef,0xbb,0xbf));
  19. fopen($id,"r");
  20. fclose($fp);
  21. //End 4
  22. //5 - Otwarcie pliku
  23.  
  24.  
  25.  
  26. if (file_exists($id)) {
  27. header('Content-Description: File Transfer');
  28. header('Content-Type: application/octet-stream');
  29. header('Content-Disposition: attachment; filename='.basename($id));
  30. header('Content-Transfer-Encoding: binary');
  31. header('Expires: 0');
  32. header('Cache-Control: must-revalidate');
  33. header('Pragma: public');
  34. header('Content-Length: ' . filesize($id));
  35. flush();
  36. readfile($id);
  37. }


Jak sobie z tym poradzić?
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 21.08.2025 - 02:53