Jump to content

[SOLVED] Rename function Error


Suchy

Recommended Posts

I have a simple script to rename files.

 

<?php
$path = 'fotki_upload';
$dir_handle = opendir($path);

while ($file = readdir($dir_handle)) 
   rename($file, strtoupper($file));

closedir($dir_handle);
?> 

 

But I am getting these errors.

Warning: rename(wixa.jpg,WIXA.JPG) [function.rename]: No such file or directory in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(.,.) [function.rename]: Device or resource busy in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(1.jpg,1.JPG) [function.rename]: No such file or directory in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(3.jpg,3.JPG) [function.rename]: No such file or directory in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(index.html,INDEX.HTML) [function.rename]: No such file or directory in /home/suchygn/public_html/media/fotka/rename.php on line 9

Warning: rename(..,..) [function.rename]: Device or resource busy in /home/suchygn/public_html/media/fotka/rename.php on line 9

 

What seems to be the problem, the direcotry where the files are i chomed to 777.

Link to comment
https://forums.phpfreaks.com/topic/49086-solved-rename-function-error/
Share on other sites

// The mistake you make, is very common

// you forgot to include the path, because the file 1.jpg does not exist

// in your current directory, but it exists in your upload_folder/1.jpg

while ($file = readdir($dir_handle)) {

  if ($file <> "." && $file <> "..") {

     $full = $path . DIRECTORY_SEPERATOR . $file;

     rename($full, strtoupper($full));

  }

}

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.