|
To rename upload files based on the ID field use the following code in
Add page: Before record added
and/or Edit page: Before record
updated events.
Note: Change
the values listed in red to
match your specific needs.
|
global $pageObject;
foreach( $pageObject->filesToMove as
$key=>$val)
{
if($pageObject->filesToMove[$key]->sourceFilename==$_FILES["value_FieldName_".postvalue("id")]["tmp_name"])
$pageObject->filesToMove[$key]->destFilename=
$values["ID"].".jpg";
}
$values["FieldName"] = $values["ID"].".jpg";
|
In this example FieldName stores the name of uploaded
file.
Note: If ID is
a key column you need to use $keys["ID"] instead of $values["ID"]. ID cannot be an
autoincrement key column as it's value is not yet available in
BeforeAdd event.
|