Hi there!
I'm making an upload script, where I want to replace ":" with "-" - ex: "USER_ID:1345" with "USER_ID-1345". Also I was wondering how I can find the file extension - ex: ".rar".
Upload script - replace and file extension.
Moderator: General Moderators
Upload script - replace and file extension.
Last edited by JKM on Fri Dec 19, 2008 3:19 pm, edited 1 time in total.
-
mukul_chou
- Forum Newbie
- Posts: 5
- Joined: Tue Jun 17, 2008 4:23 am
Re: Upload script - replace and file extention.
tryI want to replace
Code: Select all
str_replace ()explode() the file name string against . (period) and the last element of the arry is your extension. orhow I can find the file extention
try
Code: Select all
substr()there is a file out there called php.chm Try to find this. this is the php ref manual. this file is extremely helpful.
Re: Upload script - replace and file extention.
Like this?
and
Code: Select all
str_replace($userid, "USER_ID:", "USER_ID-")Code: Select all
$file_extension = substr($filename , strrpos($filename , '. ') +1);
if($file_extension != "rar") {
echo "The file isn't a rar file!";
}