Faplo Posted November 12, 2004 Report Share Posted November 12, 2004 Ja piem es failus lieku caur ftp serveri. Ka iespejam ieejot web lapa it ka atvert source php failam un to pamanit pec tam saglabat? Nu vinam vajadetu atverties kaut kada redigejamaa laukumaa :/ piem textbox? plx palidziet :huh: Link to comment Share on other sites More sharing options...
рпр Posted November 12, 2004 Report Share Posted November 12, 2004 tieshi taa, tu to failu vari ielaadeet formas textareaa un tad labot, submitojot formu tu to visu saglabaa atkal failaa. nepiecieshamaas funkcijas tev buus fopen, lai nolasiitu un saglabaatu failu, fread, fwrite, fclose. php failiem ,ko gribi labot caur webu ir jaabuut ar tiesiibaam tajos rakstiit ikvienam lietotaajam, shajaa gadijiumaa tes lietotaajs buus webserveris. Link to comment Share on other sites More sharing options...
Faplo Posted November 12, 2004 Author Report Share Posted November 12, 2004 Plz izpalidzi un uzdruka kodu nu vismaz apmeram B) lai domu saprastu . Btw ka ieladet text boxaa failu? Link to comment Share on other sites More sharing options...
bubu Posted November 12, 2004 Report Share Posted November 12, 2004 echo '<textarea name="fails">' . htmlspecialchars(file_get_contents('fails.php')) . '</textarea>'; Link to comment Share on other sites More sharing options...
Faplo Posted November 12, 2004 Author Report Share Posted November 12, 2004 Ja tnx par otro jautajuma atbildesanu bet uz pirmo jautajumu kads var atbildet? Link to comment Share on other sites More sharing options...
Faplo Posted November 12, 2004 Author Report Share Posted November 12, 2004 man radas tads mulkigs question ka var spiezot uz buttona nosutit datus vinus ieraxtot faila, bet kad uzpiez uz button nevis ielade lapu vai tml. !!! Pats isti nezinu :/ Link to comment Share on other sites More sharing options...
Gacha Posted November 12, 2004 Report Share Posted November 12, 2004 Tev derētu iemācīties to, kas ir $_POST['textbox_data'] Un pпp tev jau teica, kadas f-cijas tev vajadzīgas: fread, fwrite, fclose. Tad, ja gribi ierakstīt skatiesmanuālī, tur takš ir smuks piemērs! Link to comment Share on other sites More sharing options...
bubu Posted November 12, 2004 Report Share Posted November 12, 2004 (edited) Jā ar POST pieprasījumu var. Var arī darīties kruti ar XMLHttpRequest objektu: html kods: <html> <head> <script> var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof(XMLHttpRequest)!='undefined') { xmlhttp = new XMLHttpRequest(); } function SendData() { if (!xmlhttp) { return true; } data = escape(document.forms[0].data.value); xmlhttp.open('GET', 'a.php?data='+data, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { document.getElementById('status').innerHTML = xmlhttp.responseText; } } xmlhttp.send(null); return false; } </script> </head> <body> <form action="a.php" method="get" onsubmit="return SendData();"> Nosuutaamie dati: <input type="text" name="data" /><br/> <input type="submit" value="Suutiit" /><br/> Rezultaats:<span id="status"><p>Dati veel nav nosuutiiti</p></span> </form> </body> </html> php kods: <?php header('Content-Type: text/xml'); if (!isset($_GET['data'])) { echo '<p>Nekorekts pieprasiijums!</p>'; die(); } $f = @fopen('fails.txt', 'a'); if ($f===false) { echo '<p>Kljuuda atverot failu!</p>'; die(); } if (@fwrite($f, $_GET['data']) === false) { echo '<p>Kljuuda rakstot failaa!</p>'; die(); } @fclose($f); echo '<p>Dati veiksmiigi ierakstiiti! Zinjojuma garums='.strlen($_GET['data']).'</p>'; ?> Edited November 12, 2004 by bubu Link to comment Share on other sites More sharing options...
Faplo Posted November 12, 2004 Author Report Share Posted November 12, 2004 (edited) Vai kads vienk. nevaretu php uzraxtit kaut ko tadu ka scp atver failu lauj to manit kad spiez saglabat vins to saglaba. un viss :/ Edited November 12, 2004 by Faplo Link to comment Share on other sites More sharing options...
Faplo Posted November 12, 2004 Author Report Share Posted November 12, 2004 Tikai plz bez xml :/ plzzz :unsure: Link to comment Share on other sites More sharing options...
Venom Posted November 12, 2004 Report Share Posted November 12, 2004 $path='/direktorija/ar/failiem/'; $dir=opendir($path); if (!isset($_POST['editfile'])) $_POST['editfile']=''; echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post"><select name="editfile">'; while(false!==($item=readdir($dir))) { switch ($item) { case '.': case '..': continue; default: if (is_dir($path.$item)) continue; echo '<option value="'.htmlspecialchars($item).'" '.($_POST['editfile']==$item?' selected="selected" ':'').'>'.$item; break; } } echo '</select>'; if (!empty($_POST['editfile'])) { if (isset($_POST['save']) && !empty($_POST['editable'])) { $fh=fopen($path.$_POST['editfile'],'w'); fwrite($fh,stripslashes($_POST['editable'])); fclose($fh); chmod($path.$_POST['editfile'],0755); } echo '<br><textarea style="width:90%;height:500px" name="editable">'.htmlspecialchars(@file_get_contents($_POST['editfile'])).'</textarea><br /><input name="save" value="save" /> '; } echo '</form>'; rakstīts tepat textareā, varētu būt kļūdas whatever sākums tev iraid Link to comment Share on other sites More sharing options...
Faplo Posted November 12, 2004 Author Report Share Posted November 12, 2004 (edited) Man jautajums kapec sis te ? $faila_vards = 'texts.txt'; if (isset($submit)) { $str = $faila_saturs; $faila_v = fopen("$faila_vards", "w"); fwrite($faila_v, $str); fclose($faila_v); } $faila_vards = 'texts.txt'; $faila_saturs = htmlspecialchars(file_get_contents($faila_vards)); echo'<form action="'.$_SERVER['PHP_SELF'].'" method="post">'; echo'<textarea name="faila_texts" cols="100" rows="40">'. $faila_saturs .'</textarea>'; echo'<input type="submit" name="submit" value="Save">'; echo'</form>'; ?> nedarbojas????? Tipa vins neraxta to textu kas textboxaa? Edited November 12, 2004 by Faplo Link to comment Share on other sites More sharing options...
Venom Posted November 12, 2004 Report Share Posted November 12, 2004 droši vien nesaprot no kurienes jārodas tam $submit, izmanto $_POST['submit']? Link to comment Share on other sites More sharing options...
Faplo Posted November 12, 2004 Author Report Share Posted November 12, 2004 nea vienalga tip es spiezu save bet vins neko neieraxta failaaa :/ atver tuksu text box :angry: Link to comment Share on other sites More sharing options...
Venom Posted November 12, 2004 Report Share Posted November 12, 2004 (edited) nu tad varbūt viņš pārraksta to faili tukšu, jo $faila_vards = 'texts.txt'; if (isset($submit)) { $str = $faila_saturs; $faila_v = fopen("$faila_vards", "w"); fwrite($faila_v, $str); fclose($faila_v); } mainīgais nav ielasīts. ar register_globals=on laikam jābūt file_text? Edited November 12, 2004 by Venom Link to comment Share on other sites More sharing options...
Recommended Posts