I want to change the file name when uploading. I tried to do this by callbacks. But didn't work any of them.
Method 1 - using callback_before_upload
function callback1($files_to_upload,$field_info)
{
foreach($files_to_upload as $value) {
$value['name']='pp.pdf';
}
}
Method 2 - using callback_after_upload
function callback2($uploader_response,$field_info, $files_to_upload)
{
foreach($files_to_upload as $value) {
$uploader_response[0]->name='pp.pdf';
}
return true;
}
Method1 ddnt work at all. In method2, file name at database changed to pp.pdf, but uploaded file in upload directory ddnt change at all. So my question is how to rename the file when uploading. Can anyone please help me?