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
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.
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
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