Contents

 
Home
PHPRunner 6.1 manual
Prev Page Next Page
 
 

Rename uploaded files

 

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.

yellowbulbNote: 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.

yellowbulbNote: 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.

Converted from CHM to HTML with chm2web Standard 2.85 (unicode)