trim filename from a string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andyau

    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
  • Lars Eighner

    #2
    Re: trim filename from a string

    In our last episode,
    <64a6e4c0-de94-4db5-ab67-01c955eb1442@q2 7g2000prf.googl egroups.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@larseigh ner.com
    Countdown: 294 days to go.

    Comment

    • Krustov

      #3
      Re: trim filename from a string

      <comp.lang.ph p>
      <andyau>
      <Tue, 1 Apr 2008 03:45:26 -0700 (PDT)>
      <64a6e4c0-de94-4db5-ab67-01c955eb1442@q2 7g2000prf.googl egroups.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']); ?>


      --

      Comment

      • andyau

        #4
        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...@privacy.n etwrote:
        <comp.lang.ph p>
        <andyau>
        <Tue, 1 Apr 2008 03:45:26 -0700 (PDT)>
        <64a6e4c0-de94-4db5-ab67-01c955eb1...@q2 7g2000prf.googl egroups.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

        Comment

        Working...