Simple Machines Community Forum

General Community => Scripting Help => Topic started by: mickjav on January 28, 2022, 10:47:28 AM

Title: Remove File Extension
Post by: mickjav on January 28, 2022, 10:47:28 AM
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
Title: Re: Remove File Extension
Post by: Aleksi "Lex" Kilpinen on January 28, 2022, 11:43:45 AM
Sorry I don't know how to help, but I am really curious as to why?
Title: Re: Remove File Extension
Post by: mickjav on January 28, 2022, 11:57:01 AM
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 (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
Title: Re: Remove File Extension
Post by: Aleksi "Lex" Kilpinen on January 28, 2022, 12:27:12 PM
Thanks for the explanation, and for sharing your answer :)
Title: Re: Remove File Extension
Post by: mickjav on January 28, 2022, 12:38:23 PM
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.
Title: Re: Remove File Extension
Post by: mickjav on January 28, 2022, 02:24:00 PM
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
Title: Re: Remove File Extension
Post by: Mick. on January 28, 2022, 07:03:44 PM
Guests don't have access to that image