Re: how to trim file path from filename



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 to
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?
The traditional directory separator is regular slash ('/'), but Winoid
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
.



Relevant Pages

  • Re: Apply LEN result to string?
    ... > If the end result is to strip the extension off a filename then you could do ... > Public Function RemoveExtension(ByVal FileName As String, ... > Public Function RemoveExtensionAs String ...
    (microsoft.public.excel.programming)
  • Re: Apply LEN result to string?
    ... If the end result is to strip the extension off a filename then you could do ... Public Function RemoveExtension(ByVal FileName As String, ... Using VB to fetch the filename and placing it in cell B1., ...
    (microsoft.public.excel.programming)
  • another NullPointerException problem with List interface
    ... The API says that addcan have this exception "if the ... prints out the filename). ... 45 public static ListlistAllFiles(File dir, String ... extension) throws Exception ...
    (comp.lang.java.programmer)
  • Re: splitFullFileName error ??
    ... ExtraPath string;any path deeper than alias ... FileNOext string;\\file name when file passed has no extension ... fileName string;file name ...
    (comp.databases.paradox)
  • Re: vb6 path
    ... I am using VB6. ... i have a string that contains a path + file name. ... the character position of last backslash, "\", then ... use Mid$ or Right$ to get the filename. ...
    (microsoft.public.vb.general.discussion)