Stripping extensions and making a directory...

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

nindoja
New php-forum User
New php-forum User
Posts: 6
Joined: Wed Jan 08, 2003 4:45 pm

Stripping extensions and making a directory...

Postby nindoja » Wed Jun 25, 2003 5:48 pm

Hello. How would I take the name of an uploaded file (variable is $file), and remove the extension (either .8xp or .zip)??? Also, how would I take that new variable, and make a directory with that new name??? Thanks.

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Wed Jun 25, 2003 5:57 pm

there are several way you can do that. an easy way that I do it is to explode the name by '.' and use mkdir() to create a new directory.

Code: Select all

$filename_array = explode('.',$filename);
$directory_name = $filename_array[0];
mkdir($directory_name);

nindoja
New php-forum User
New php-forum User
Posts: 6
Joined: Wed Jan 08, 2003 4:45 pm

Thanks.

Postby nindoja » Thu Jun 26, 2003 8:33 am

Thanks. That worked.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest