Mzor Posted March 3, 2009 Share Posted March 3, 2009 I need to find a way to change the name of an uploaded file, but keep the extension type. If I use $_FILES['filename']['type'], it doesn't give me just the extension, so I need a way to retrieve just the extension so I can tack it on to the url where I want to copy the file to. Thanks. Link to comment https://forums.phpfreaks.com/topic/147803-renaming-uploaded-files/ Share on other sites More sharing options...
cooldude832 Posted March 3, 2009 Share Posted March 3, 2009 do print_r($_FILES); and figure out whats in there lots of good info Link to comment https://forums.phpfreaks.com/topic/147803-renaming-uploaded-files/#findComment-775817 Share on other sites More sharing options...
Mzor Posted March 3, 2009 Author Share Posted March 3, 2009 The only output is: "Array ( )" Link to comment https://forums.phpfreaks.com/topic/147803-renaming-uploaded-files/#findComment-775821 Share on other sites More sharing options...
laffin Posted March 3, 2009 Share Posted March 3, 2009 try using strrchr $file = md5(microtime(true)) . strtolower(strrchr($_$FILES['file']['name'],'.')); but ya may want to validate a proper extension maybe a pregmatch only dots and alpha num if(!preg_match('@^[\w.-=]+$@',$_FILES['file']['name']) die('Bad Filename'); well ya gets the picture Link to comment https://forums.phpfreaks.com/topic/147803-renaming-uploaded-files/#findComment-775841 Share on other sites More sharing options...
cooldude832 Posted March 4, 2009 Share Posted March 4, 2009 well u have to upload a file for it to be existant Link to comment https://forums.phpfreaks.com/topic/147803-renaming-uploaded-files/#findComment-776079 Share on other sites More sharing options...
laffin Posted March 5, 2009 Share Posted March 5, 2009 That usually helps Link to comment https://forums.phpfreaks.com/topic/147803-renaming-uploaded-files/#findComment-776984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.