Привет У меня есть проблема с этим кодом с кодом я могу изменить весь мой файл папки на номер, как 1.mp4 2.mp4 ЭСТ ...переименования файла не работает на PHP
я проверить код и я напечатать имя файла из него, и каждая вещь правильно но переименовывать функция не работает это мой код
$dir = opendir('.');
$i = 1;
// loop through all the files in the directory
while (false !== ($file = readdir($dir)))
{
// if the extension is '.mp4'
if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'mp4')
{
echo $file ;
// do the rename based on the current iteration
$newName = $i . '.mp4';
rename($file, $newName);
// increase for the next loop
$i++;
}
}
// close the directory handle
closedir($dir);
?>
чем проблема сейчас?
NEW INfO
i tried the code inside my localhost and it's work but it's not working inside the server
'$ i' должен быть строкой. '$ i = '1';' – DinukaD
yes i инициализировать его во второй строке –
'$ i = 1;' не '$ i = '1';' – DinukaD