Jump to content

[SOLVED] newbie question


jtown

Recommended Posts

here is my code

The directory name are coming from my form fields right?

Thanks

<?

$old = $_POST['oldname'];

$new = $_POST['newname'];

rename('$old', '$new');

$dir = opendir("images");

while ($file = readdir($dir))

{

echo "current filename:  $file\n";

?>

<form action="<? echo($PHP_SELF)?>" >

<input type="hidden" name="oldname" />

<input type="text" name="newname" size="30"/><br />

<input type="button" value="change file name"/><br /><br />

</form>

<?

}

 

closedir($dir);

 

?>

Thanks man, but why am I getting the following error

 

Warning: rename(,) [function.rename]: No such file or directory in /home/mmaaaco/public_html/jfanning/mm2232midterm/question_1.php on line 14

 

here is my code

I'm new at this shit and am having a hard time wrapping my head around it

 

 

$imgold = "images/GSP_02.Jjpg";

$dir = opendir("images");

$old = $_POST['oldname'];

$new = $_POST['newname'];

rename("$old", "$new");

 

while ($file = readdir($dir))

{

echo "current filename:  $file\n";

?>

<form action="<? echo($PHP_SELF)?>" method="post">

<input type="hidden" name="oldname" />

<input type="text" name="newname" size="30"/><br />

<input type="submit" value="change file name"/><br /><br />

</form>

<?

}

 

closedir($dir);

 

Thanks

here is all the code

 

print_r($_POST);

$imgold = "images/GSP_02.Jjpg";

$dir = opendir("images");

$old = $_POST['oldname'];

$new = $_POST['newname'];

rename("$old", "$new");

 

while ($file = readdir($dir))

{

if($file == '.' or $file == '..'){ continue; }

echo "current filename:  $file\n";

?>

<form action="<? echo($PHP_SELF)?>" method="post">

<input type="hidden" name="oldname" />

<input type="text" name="newname" size="30"/><br />

<input type="submit" value="change file name"/><br /><br />

</form>

<?

}

 

closedir($dir);

 

Thanks man

<?php
if (isset($_POST)) {

$dir = opendir("images");
$old = $_POST['oldname'];
$new = $_POST['newname'];
rename("$old", "$new");
echo "$old renamed to $new. <br />";
}

   while ($file = readdir($dir))
      {
      if($file == '.' or $file == '..'){ continue; }
      echo "current filename:  $file\n";
      ?>
      <form action="<? echo($PHP_SELF)?>" method="post">
      <input type="hidden" name="oldname" />
      <input type="text" name="newname" size="30"/>

      <input type="submit" value="change file name"/>


      </form>
      <?
      }

   closedir($dir);
?>

 

Try that.  Should work.

Why do I get the same error about the directory???

 

Warning: rename(,dgfdgf) [function.rename]: No such file or directory in /home/mmaaaco/public_html/jfanning/mm2232midterm/question_1.php on line 15

 

My images that I'm trying to rename are in my images folder.

line 15 has my rename function

Ah, I see the issue.  Here:

<?php
if (isset($_POST)) {

$dir = opendir("images");
$old = $_POST['oldname'];
$new = $_POST['newname'];
rename("$old", "$new");
echo "$old renamed to $new. <br />";
}

   while ($file = readdir($dir))
      {
      if($file == '.' or $file == '..'){ continue; }
      echo "current filename:  $file\n";
      ?>
      <form action="<? echo($PHP_SELF)?>" method="post">
      <input type="hidden" name="oldname" value="<?php echo $file ?>" />
      <input type="text" name="newname" size="30"/>

      <input type="submit" value="change file name"/>


      </form>
      <?
      }

   closedir($dir);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.