This topic is locked

Basic upload change filename

10/20/2020 11:45:05 AM
PHPRunner Tips and Tricks
K
kdgsv author

Hallo,
I've found the code below here in the forum:
It is menioned there this code appliesto PhphRunner 6.x to 8.x
Does this mean this code will not work at the current version of Phprunner?
If not, does someone have an updates code sample whic will work with the current version of PHPRunner?
Thank you.

Matthias

// field name that stores uploaded file name

$field="UploadFieldName";
global $pageObject;

foreach( $pageObject->filesToMove as $key=>$val)

{

if($pageObject->filesToMove[$key]->sourceFilename==$_FILES["value_".$field."_".postvalue("id")]["tmp_name"]) {
$fileName = $values[$field];

$ext = ".".pathinfo($fileName, PATHINFO_EXTENSION);

$name = basename($fileName, $ext);

$newFileName = $name."_".date('YmdHis').$ext;

$values[$field]=$newFileName;

$pageObject->filesToMove[$key]->destFilename = $newFileName;

}

}
return true;