News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Remove File Extension

Started by mickjav, January 28, 2022, 10:47:28 AM

Previous topic - Next topic

mickjav

Tried a number of ways to do this but this is the one that don't brake the site
Found the code on Stack Overflow All I have managed to do is remove the file name
$newFileName = $_FILES['picture']['name'][$n];
$title = $smcFunc['htmlspecialchars'](substr($newFileName, 0 , (strrpos($newFileName, "."))),ENT_QUOTES);


Any help would be appreciated

thanks mick

Aleksi "Lex" Kilpinen

Sorry I don't know how to help, but I am really curious as to why?
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

mickjav

Quote from: Aleksi "Lex" Kilpinen on January 28, 2022, 11:43:45 AMSorry I don't know how to help, but I am really curious as to why?


If you look here https://www.databasedreams.co.uk/charts/index.php?action=gallery;sa=view;id=12632

you'll see the picture has the extension on end I wanted to remove that

I have got a answer here: https://www.smfhacks.com/index.php/topic,10148.new.html#new

Aleksi "Lex" Kilpinen

Thanks for the explanation, and for sharing your answer :)
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

mickjav

Quote from: Aleksi "Lex" Kilpinen on January 28, 2022, 12:27:12 PMThanks for the explanation, and for sharing your answer :)

Haven't got it quite right SMFHacks Is looking at the script I'll post the correction.

mickjav

Sorted It There seemed to be un-needed code As Below Commented out

//$title = $smcFunc['htmlspecialchars']($_REQUEST['title'][$n],ENT_QUOTES);

 //if (empty($title))
 //{
 //Remove Ext Edit
 $newFileName = $_FILES['picture']['name'][$n];
 $tmpFile = substr($newFileName, 0 , (strrpos($newFileName, ".")));
 $title = $smcFunc['htmlspecialchars']($tmpFile, ENT_QUOTES);
 //}

https://www.databasedreams.co.uk/charts/index.php?action=gallery;sa=view;id=12637

Mick.

Guests don't have access to that image

Advertisement: