MaxDB PHP Generator online Help
Prev | Return to chapter overview | Next |
OnFileUpload
This event allows you to control file uploading. It fires on uploading a file with Upload file to folder and Upload image to folder editors.
Signature:
function OnFileUpload($fieldName, &$result, &$accept, $originalFileName,
$originalFileExtension, $fileSize, $tempFileName)
Parameters:
$fieldName |
The name of currently processed column. |
$rowData |
The associative array of values that corresponds to the currently processed row. |
$result |
The actual file name (with full path). Change the value of this parameter to customize the filename. |
$accept |
Indicates whether the file uploading is allowed. Default value is true. Set $accept to false to cancel file uploading. |
$originalFileName |
The original file name (including extension) |
$originalFileExtension |
The original file extension |
$fileSize |
The file size |
$tempFileName |
The temporary filename of the file in which the uploaded file was stored on the server. |
Example
This example shows how to add current date and time to the uploaded filename.
if ($fieldName === 'filename') {
$newFileName = date('Y-m-d_H-i-s') . "_" . $originalFileName;
$result = str_replace($originalFileName, $newFileName, $result);
}
Prev | Return to chapter overview | Next |