web_master Posted January 24, 2009 Share Posted January 24, 2009 Hi, I got a problem with file uplaod. When I upload the file, I want to change the file name only but to leave original file extenstion. example: original file is: my file.doc saved file is: 1_5_text.doc <?php move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/142260-solved-upload-file-change-filename-but-extension-dont-chage/ Share on other sites More sharing options...
MadTechie Posted January 24, 2009 Share Posted January 24, 2009 <?php $filename = "Myfile.txt"; $file_ext = strrchr($filename, '.'); //gets .txt $newfile = "Whatever".$file_ext; //=Whatever.txt ?> Quote Link to comment https://forums.phpfreaks.com/topic/142260-solved-upload-file-change-filename-but-extension-dont-chage/#findComment-745309 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.