Re: how to trim file path from filename
- From: Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@xxxxxxxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 18:34:29 +0200
Tom Cole schreef:
On Mar 31, 11:24 am, Bart Van der Donck <b...@xxxxxxxxxx> wrote:andyau wrote:I am uploading a file to the server and at the same time I want toThe traditional directory separator is regular slash ('/'), but Winoid
place the file name in to a database.
But for the the file to be effective I need to trim the path from the
filename and leave just the filename.
Can anyone suggest how I do this?
systems generally use backslash ('\'). But a file or directory name in
UNIX may contain backslash as well.
One way is to detect which of the slashes comes first, and take that
as separator for what follows. This should be a reasonably safe
assumption (I can't think of an alternative criterion).
Hope this helps,
--
Bart
I don't think PHP filesystem functions has a method to return filepath
separators (for example java does...)
Hi Bart,
What about this?
[from http://nl2.php.net/dir]
Predefined Constants
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
DIRECTORY_SEPARATOR (string)
PATH_SEPARATOR (string)
Regards,
Erwin Moller
.
- References:
- how to trim file path from filename
- From: andyau
- Re: how to trim file path from filename
- From: Bart Van der Donck
- Re: how to trim file path from filename
- From: Tom Cole
- how to trim file path from filename
- Prev by Date: Re: Writing to iframe issue with Internet Explorer
- Next by Date: Re: how to trim file path from filename
- Previous by thread: Re: how to trim file path from filename
- Next by thread: Re: how to trim file path from filename
- Index(es):
Relevant Pages
|