trim filename from a string

trim filename from a string

am 01.04.2008 12:45:26 von andyau

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

Re: trim filename from a string

am 01.04.2008 12:58:02 von Lars Eighner

In our last episode,
<64a6e4c0-de94-4db5-ab67-01c955eb1442@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 usenet@larseighner.com
Countdown: 294 days to go.

Re: trim filename from a string

am 01.04.2008 13:40:46 von Hans-Peter Sauer




<64a6e4c0-de94-4db5-ab67-01c955eb1442@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
>




--
www.krustov.co.uk

Re: trim filename from a string

am 01.04.2008 14:04:40 von andyau

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 wrote:
>
>
>
> <64a6e4c0-de94-4db5-ab67-01c955eb1...@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
>
>
>
> --www.krustov.co.uk