Path with File Problem [Solved]

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Tue Oct 25, 2005 4:03 am    Post subject: Path with File Problem [Solved] Reply with quote

This was currently a problem with trying to remove a file name from the path.
Whats even funnier is that I did'nt need to do this because its a Index Listing
script that will be used in ::File Limit:: v2. Aprelium can delete this :-)

Thanks for those who've already helped me with this issue.

Sincerely , TRUSTpunk


Last edited by TRUSTAbyss on Tue Oct 25, 2005 5:43 am; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Oct 25, 2005 4:18 am    Post subject: Reply with quote

It's not really tidy, and I'm not really awake, but something like this might work.
Code:
function removefilename($input) {
  $dir = explode("/", $input);
  for ($count = 1, $dir_result = "/"; ($count+1) < count($dir); $count++) {
    $dir_result .= $dir[$count]."/";
  }
  return $dir_result;
}
$dir = dirname(removefilename("/music/rock/offspring/*file.mp3*"));
echo "Parent Directory: ".$dir;

(Can't be arsed to put it into theory, 'tis 4AM.)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Tue Oct 25, 2005 4:28 am    Post subject: Reply with quote

I edited my first post to explain how stupid this issue is. I did'nt have it
in my brain at the time that this is going to be a Directory Listing script.

Code:

<?php
/*

This code will get the Parent Directory , which is
useful when you create a Directory Listing script.

*/

$dir = "/music/rock/offspring/";
echo "Parent Directory: " . dirname($dir);

// Will return /music/rock
?>


Note: If you ever create a Directory Listing script , you have to do more than
just add this piece of code in order to make it bug free , this code works. :-)

Sincerely , TRUSTpunk


Last edited by TRUSTAbyss on Tue Oct 25, 2005 5:48 am; edited 6 times in total
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Oct 25, 2005 4:32 am    Post subject: Reply with quote

Apparantly I do things the hard way. Not seen that function before, either.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group