trim filename from a string

I am receiving a string which has in it a full path of the file the
user entered in a previous form. I would like to trim just the file
name from this string.
So rather than having users/andy/images/image.jpg I insert only
image.jpg in to my database table.

I am receiving this as a string not as a multipart form submit the
file has already been placed on the server by this stage.

Thank you in advance for any help.

Cheers
Andy
andyau [ Di, 01 April 2008 12:45 ] [ ID #1933089 ]

Re: trim filename from a string

In our last episode,
<64a6e4c0-de94-4db5-ab67-01c955eb1442 [at] q27g2000prf.googlegroups.com>,
the lovely and talented andyau
broadcast on comp.lang.php:

> I am receiving a string which has in it a full path of the file the
> user entered in a previous form. I would like to trim just the file
> name from this string.
> So rather than having users/andy/images/image.jpg I insert only
> image.jpg in to my database table.

see pathinfo() in the manual.

> I am receiving this as a string not as a multipart form submit the
> file has already been placed on the server by this stage.

--
Lars Eighner <http://larseighner.com/> usenet [at] larseighner.com
Countdown: 294 days to go.
Lars Eighner [ Di, 01 April 2008 12:58 ] [ ID #1933090 ]

Re: trim filename from a string

<comp.lang.php>
<andyau>
<Tue, 1 Apr 2008 03:45:26 -0700 (PDT)>
<64a6e4c0-de94-4db5-ab67-01c955eb1442 [at] q27g2000prf.googlegroups.com>

> I am receiving a string which has in it a full path of the file the
> user entered in a previous form. I would like to trim just the file
> name from this string.
> So rather than having users/andy/images/image.jpg I insert only
> image.jpg in to my database table
>

<?php $temp=basename($_SERVER['PHP_SELF']); ?>


--
www.krustov.co.uk
Hans-Peter Sauer [ Di, 01 April 2008 13:40 ] [ ID #1933093 ]

Re: trim filename from a string

I currently have

$photo = basename( $_GET['myfile']['name']);

also tried $temp=basename($_SERVER['PHP_SELF']);

Changing the relevant elements.

The element that is coming in on the string is myfile and what is
being inserted into the database is photo.


On Apr 1, 12:40 pm, Krustov <m... [at] privacy.net> wrote:
> <comp.lang.php>
> <andyau>
> <Tue, 1 Apr 2008 03:45:26 -0700 (PDT)>
> <64a6e4c0-de94-4db5-ab67-01c955eb1... [at] q27g2000prf.googlegroups.com>
>
> > I am receiving a string which has in it a full path of the file the
> > user entered in a previous form. I would like to trim just the file
> > name from this string.
> > So rather than having users/andy/images/image.jpg I insert only
> > image.jpg in to my database table
>
> <?php $temp=basename($_SERVER['PHP_SELF']); ?>
>
> --www.krustov.co.uk
andyau [ Di, 01 April 2008 14:04 ] [ ID #1933098 ]
PHP » comp.lang.php » trim filename from a string

Vorheriges Thema: Is Apache Needed w/IIS (Windows 2003) for PHP Install
Nächstes Thema: how can i make a download through php