Jump to content
php.lv forumi

Kļūda izmantojot fopen (php $_GET)


-=HELLBENDER=-

Recommended Posts

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Īsti nesaprotu ko tu ar to domāji, bet nu izskatās šādi un kļūda nemainīga;

 

<?php
$fn = $_GET["fname"];
var_dump($_GET["fname"]);
if (isset($_GET['content']))
{	
$fn = $_GET["fname"];
if (file_exists($fn)) {
   echo "The file $filename exists<p>";
} else {
   echo "The file $filename does not exist<p>";
}
var_dump($_GET["fname"]);
   $fp = file_get_contents($fn, true) or die ("Error opening file in write mode!");
   file_put_contents($fp,$content);
}
?>
<p>
<form action="edit.php" method="get">
   <textarea rows="30" cols="80" name="content"><?php readfile($fn); ?></textarea>
   <input type="submit" value="Edit"> 
</form>

Link to comment
Share on other sites

Ko Tu nesaproti?

Pirmajā postā kur ieliki kodu, Tu to padod ar POST mainīgo "fname" un saņemt nez kāpēc centies ar $fn = $_GET['fname'];

Kā Tev liekas, bez register globals on tas darbojas?

EDIT: un jā, tikai nemēģini to register globals on panākt, emm..,uzstādijumos...,iestatījumos, kā pareizāk, nezinu.

Edited by mounkuls
Link to comment
Share on other sites

Debugo lēnām un mierīgi. Ko saka file_exists? Ja false, tad skaties vai failu meklē pareizajā ceļā (ja taisi file_get_contents('file.php') nevis file_get_contents('/path/to/file.php'), tad skaties, kura ir pašreizējā direktorija no kuras php mēģinās to failu atrast)

 

Un jā - tev tas fname ir urlī?

Edited by rATRIJS
Link to comment
Share on other sites

Failam ir jābūt, pat ja lieto 'w' opciju fopen, failu iztukšo un raksta no jauna. Pat ja neko neieraksta, failam ir jāpastāv.

Bet nu debugging mode jau ir smadzenēs. echo 'step' un print_r(vars) apmēram

ini_set('display_errors', 1);

Edited by mounkuls
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...