Hi PHPRunner Team and forum members :-)
I have a menu item called "options" that is only available as a list view and edit record. There are two upload image fields on this form - only allowing 1 image each. 1 is called "wallp" and the other "logo" I would like the user to be able to upload any image xxxxx.png to field "logo" and have it renamed by code to logo.png (physical file name) every time and to over-write as well.
The same for "wallp" and have it renamed by code to wallpaper.jpg
In trial I tried, My link
By making read-only fields called "logoname" and "wallname" and added the vales "logo" and "wallpaper" to those fields with phpmyadmin. Seems like a clumsy way to go about it and I was not able to combine the two blocks of code in the same event. When I used the blocks of code 1 at a time (in event edit page before update) I would get logo0.png
// get information about uploaded files LOGO
$fileArray = my_json_decode($values["logo"]);
// rename files
for($i = 0; $i < count($fileArray); $i++)
{
$fileName = $fileArray[$i]["name"];
$newFileName = "zreportfiles/art/".$values["logoname"].$i.".png";
rename($fileName, getabspath($newFileName));
$fileArray[$i]["name"] = $newFileName;
}
$values["logo"] = my_json_encode($fileArray);
return true;
$fileArray = my_json_decode($values["wallp"]);
for($i = 0; $i < count($fileArray); $i++)
{
$fileName = $fileArray[$i]["name"];
$newFileName = "zreportfiles/art/".$values["wallname"].$i.".jpg";
rename($fileName, getabspath($newFileName));
$fileArray[$i]["name"] = $newFileName;
}
// update values of the field that stores file names
$values["wallp"] = my_json_encode($fileArray);
return true;
Not sure id this is the best way to go about it. Would prefer to just rename the file on upload
Thanks for any help or suggestions