Manual talk:Hooks/UploadForm:BeforeProcessing

Is it possible to change image name after upload? For example, I want to upload image1.jpg (ignore warnings = 0), but file with this name already exists. I need change image name to image1_000.jpg where 000 - random number.

$wgHooks['UploadVerification'][] = 'wfOnUploadVerifyFile';

function wfOnUploadVerifyFile($saveName, $tempName, &$error) {

$title = Title::newFromText( "File:".$saveName );

$nameExists = $title->exists();

if ($nameExists) {

$extension_pos = strrpos($saveName, '.');
$saveName = substr($saveName, 0, $extension_pos) . '_thumb' . substr($saveName, $extension_pos);

}

ob_start();
print_r($saveName);
$tratata = ob_get_contents();
ob_end_clean();
ob_start();
echo "<pre>";
echo htmlspecialchars($tratata);
echo "</pre>";
$tratata = ob_get_contents();
ob_end_clean();
echo $tratata;

return true;

}

This what I have now. In $saveName file name what I need. But I dont know how change result name. — Preceding unsigned comment added by Netsu (talkcontribs)

Start a discussion about Manual:Hooks/UploadForm:BeforeProcessing

Start a discussion
Return to "Hooks/UploadForm:BeforeProcessing" page.