It will update the DB of course, but it's the filename itself that isn't renaming.
I'm probably going wrong in the 'source' but.
A bit of guidance please. thanks.
Code: Select all
$photoprimaryname = isset($_POST['photoprimaryname']) ? $_POST['photoprimaryname'] : null;
$photoprimarynewname = isset($_POST['photoprimarynewname']) ? $_POST['photoprimarynewname'] : null;
if (isset($photoprimarynewname))
{
$photoprimarynamesource = "../$photoprimaryname";
$photoprimarynewnamesource = "../$photoprimarynewname";
mysql_query ("UPDATE products SET photoprimary = '$photoprimarynewname' WHERE id = '$id'");
$renameResult = rename($photoprimarynamesource, $photoprimarynewnamesource);
// Evaluate the value returned from the function if needed
if ($renameResult == true) {
echo $target . " is now named " . $newName;
} else {
echo "Could not rename that file";
}
}