doubledee Posted February 21, 2012 Share Posted February 21, 2012 I have a variable that holds the name of a File... $origFileName = $_FILES['userPhoto']['name']; What is the best way to just get the File Name from this? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/257442-file-name-with-extension/ Share on other sites More sharing options...
QuickOldCar Posted February 21, 2012 Share Posted February 21, 2012 I'm sorry , I misread and thought wanted the extension. pathinfo(); Quote Link to comment https://forums.phpfreaks.com/topic/257442-file-name-with-extension/#findComment-1319462 Share on other sites More sharing options...
trq Posted February 21, 2012 Share Posted February 21, 2012 I have a variable that holds the name of a File... $origFileName = $_FILES['userPhoto']['name']; What is the best way to just get the File Name from this? Debbie You just said you have a variable containing the file name already. Quote Link to comment https://forums.phpfreaks.com/topic/257442-file-name-with-extension/#findComment-1319465 Share on other sites More sharing options...
QuickOldCar Posted February 21, 2012 Share Posted February 21, 2012 I thought she meant the file name minus the extension. something like $path_parts = pathinfo($origFileName); echo $path_parts['filename']; Quote Link to comment https://forums.phpfreaks.com/topic/257442-file-name-with-extension/#findComment-1319468 Share on other sites More sharing options...
trq Posted February 21, 2012 Share Posted February 21, 2012 Or better yet: $filename = pathinfo($origFileName, PATHINFO_FILENAME); Quote Link to comment https://forums.phpfreaks.com/topic/257442-file-name-with-extension/#findComment-1319469 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.