Manual talk:Hooks/UploadForm:BeforeProcessing
Add topicAppearance
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 (talk • contribs)
Start a discussion about Manual:Hooks/UploadForm:BeforeProcessing
Talk pages are where people discuss how to make content on MediaWiki the best that it can be. You can use this page to start a discussion with others about how to improve Manual:Hooks/UploadForm:BeforeProcessing.