Re: how to trim file path from filename



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
.



Relevant Pages

  • Re: how to trim file path from filename
    ... filename and leave just the filename. ... The traditional directory separator is regular slash, but Winoid ... UNIX may contain backslash as well. ...
    (comp.lang.javascript)
  • Re: how to trim file path from filename
    ... filename and leave just the filename. ... UNIX may contain backslash as well. ... 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) ...
    (comp.lang.javascript)
  • Re: applying awk95.awk program on full pathname file
    ... using %filename% awk95.exe. ... How can I implement the backslash inside the full path name variable ... because it is translated wronlgy inside the variable %filename%? ... There are just a few commands that get confused, usually commands ...
    (comp.lang.awk)
  • Re: N00b question: creating files
    ... > backslash is an escape. ... Assuming the your filename was in quotes it would ...
    (comp.lang.php)
  • Re: A different unlink problem.
    ... I think the backslash is normally used to allow an invalid char in a ... filename by prefixing with \. ... Prev by Date: ...
    (comp.sys.ibm.as400.misc)