Zaujal mě problém s odřádkováním a nejde mi najít adekvátní a řešitelná odpovědˇ
Pomocí FOpen("xxx.txt","a") si oteřu socket a FWrite() do něj zapíšu obsah proměnné (text) a pak FClose(). Pominu-li problémy s češtinou (používam utf-8), dělá mi to blbosti s odřádkováním. Jednou je to za sebou v jednom řádku, když zase dám na konec, nebo začátek "\n" tak to vynechá řádek - jeden je prázdny, nebo jsou tam jen ty čtverečky, tedy pro script prázdny není a neumím jej donutit, aby jej přeskočil. Zkoušel jsem "\n\r" i opačně, bez něj i jednotlivě a stále to nedělá to, co chci. Předtím (na jiném hostingu) mi to nedělalo a když, řešení jsem vyzkoušel a rozchodil to. Teď si už připadám jako blbec. V PSPadu to ukazuje přesně tak, jak se chová čtení z toho souboru, NotePad ukazuje ptákoviny. Dosud jsem hostoval na windows platformách, včetně tý doma, teď jsem na linuxu a mám divný pocit, že tady je pes zakopaný.
Zná někdo řešení??? (na MySQL plánuji přejít, ale toto mě zajíma jako tech problém!)
Fórum › PHP
Jak je to vlastně s odřádkováním textu pomocí PHP uložení do souboru???

To iyo :
To iyo : Jasně. Tady je ukládácí rutina (vybírá z POST atd:
if($copy == true){ // Pokud se kopírování provede úspěšně
$oznam = "Soubor " .$_FILES['fupload']['name']. " byl úspěšně nahrán na server.\n<br>";
// a jedem na textíky do souboru
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
if($key=="uputavka") $uputavka = $val;
if($key=="detail") $detail = $val;
if($key=="jmeno") $jmeno = $val;
if($key=="prijmeni") $prijmeni = $val;
}
echo "<div style=\"font: normal 100 12px/80% sans-serif;width:100%;height:30px;text-align:center;vertical-align: text-bottom;\">Kam? Na: http://fiam.tv/".$cil."</div>"; //ASCII kód enteru
$rateimport = 0;
$vlztdrdku = $_FILES['fupload']['name'].";".$uputavka.";".$detail.";HTTP://fiam.tv/".$cil." ;".$jmeno." ".$prijmeni.";".$REMOTE_ADDR.";".date("YmdHms").";".$rateimport.";";
$vlozitdoriadku = strip_tags ($vlztdrdku,"\"");
$ffu = FOpen("test/video/video/kecy_k_videu.txt", "a+");
$texthotovy = utf8_encode($vlozitdoriadku);
//$presun = fread("test/video/video/kecy_k_videu.txt");
//$presun = rewind($ffu);
//$vlozitdoriadku .= $presun;
$zdar = FWrite ($ffu,$texthotovy); //$vlozitdoriadku
FClose ($ffu);
if($zdar==false) {
$oznam = "Texty nebyly uloženy!";
$dekan = 0;
}
}
To "$vlztdrdku" již předělávám na _MySQL, ale drhne to - už jsem to tři roky nedělal.. ;-)), ale tam bych odřádkování nemělo dělat problémy.
V kódu vidíš poslední, ještě neodmazané pokusy...
dík za zájem
Peter
Takže to dělá cache na serveru. Občas se přepíšou nově odeslaná data staršími a ty pocházejí jedině z cache.
Pomohlo uložení "natvrdo" a i když to ohlási chybu, vše funguje jak má a i odřádkování je v pohodě.
Má někdo podobnou zkušenost?

Přidej příspěvek
Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×






























































Uživatelé prohlížející si toto vlákno
Uživatelé on-line: 0 registrovaných, 117 hostů
Podobná vlákna
Načtení a uložení textu do souboru — založil avalagne
Otevření souboru a zároveň uložení textu — založil Amik98
Otevření souboru a zároveň uložení textu — založil Amik98
Stažení swf souboru pomocí php skriptu — založil Gavec
Jak se přihlásit pomocí PHP do CGI skriptu? — založil CZechBoY
Moderátoři diskuze