Hello, I have upload script that uploads a file to images/files and this script also generates a thumbnail image that is placed in images/files/thumbnail.
and in this upload script i have added a Rename button that will rename a file with a .js script that calls the script to rename a file in images/files folder and this works fine,
but i also would like to rename the file in images/files/thumbnail at the same time.
<?php
$currFileName = $_POST['currFileName'];
$newFileName = $_POST['newFileName'];
$baseDir = '../../../dead_simple_gallery/temp/images/files/';
try {
if(!preg_match('/^[a-zA-Z0-9-_\\.]+$/', $newFileName)) {
throw new Exception('Invalid filename!');
} elseif (!file_exists($baseDir . $currFileName)){
throw new Exception('The file you are trying to rename doesn\\'t exist');
} else {
if(rename($baseDir . $currFileName, $baseDir . $newFileName)){
echo "Rename successful";
} else {
throw new Exception('Could not rename file');
}
}
} catch (Exception $e) {
echo $e->getMessage();
}
?>