$file->rename($name, $safeName = true)

Renames the file and all the meta text files

  • $name (string)
    New filename
  • $safeName (boolean)
    Whether to also convert to a URL safe filename
  • return (string)
    Returns the new filename.


$file = $page->file('file-with-old-name.pdf');

try {

  echo 'The file has been renamed';

} catch(Exception $e) {

  echo 'The file could not be renamed';
  // optional reason: echo $e->getMessage();


Is something missing or incorrect? Edit this page on Github…