0
Welcome Guest! Login
0 items Join Now

ROCKETTHEME IS CLOSING ON JUNE 30, 2025. As a thank-you to our community, enjoy 50% off all themes with the promo code THANKYOU before we shut down. Read our Farewell Blog Post for more details.

How do I remove file extension from echo statement

    • mashdun's Avatar
    • mashdun
    • Sr. Rocketeer
    • Posts: 119
    • Thanks: 0

    How do I remove file extension from echo statement

    Posted 15 years 8 months ago
    • Hello all. Please excuse my ignorance on this... I am still learning PHP. I am creating a custom video upload module for my boss who needs to upload videos to the server in an easy way. He doesn't want to mess with ftp or joomla backend. Basically I have written this PHP script to upload the flv file, then displays a message with a script he can copy and paste into his blog entry.

      I have everything working, except I want to display the name of the file without the file extension.

      Here is my PHP file:
      <?php
      $target = "images/stories/video/";
      $target = $target . basename( $_FILES['uploaded']['name']) ;
      $ok=1;
       
       
      //This is our size condition
      if ($uploaded_size > 3500000)
      {
      echo "Your file is too large.<br>";
      $ok=0;
      }
       
      //This is our limit file type condition
      if ($uploaded_type =="text/php")
      {
      echo "No PHP files allowed<br>";
      $ok=0;
      }
       
      //Here we check that $ok was not set to 0 by an error
      if ($ok==0)
      {
      Echo "Sorry your file was not uploaded";
      }
       
      //If everything is ok we try to upload it
       
      else
      {
      if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
      {
      echo "File uploaded successfully! Copy the code below and paste into your blog entry. <br/><br/>{flv}". basename( $_FILES['uploaded']['name']). "{/flv}";
      }
      else
      {
      echo "Sorry, there was a problem uploading your file.";
      }
       
      ?>
      <br/><br/>
      <a href="index.php?option=com_myblog&Itemid=129">Back to Blog Homepage</a>
       

      When I upload the file it displays this:
      File uploaded successfully! Copy the code below and paste into your blog entry.

      {flv}filename.flv{/flv}

      Back to Blog Homepage

      Basically I want to remove the .flv to the filename... but having some trouble figuring it out.

      I'd appreciate any help. Thanks!
    • drsawbones's Avatar
    • drsawbones
    • Sr. Rocketeer
    • Posts: 154
    • Thanks: 0
    • Joomla Adict

    Re: How do I remove file extension from echo statement

    Posted 15 years 7 months ago
    • Hi,

      Cool beans...I have a client that is afraid to touch Joomla, too. doh.
      I'm not a php guru or anything, just knew about strrpos so googled, am hopeful this should get you on your way:
      $name = substr($fileName, 0, strrpos($fileName, '.'));

      Regards,
      Doc

Time to create page: 0.067 seconds