Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8519195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:10:58+00:00 2026-06-11T06:10:58+00:00

I have written a small php script which reads file names from a directory,

  • 0

I have written a small php script which reads file names from a directory, uses explode to get rid of the extension and then displays the file name on a php page.

But for some reason, whenever the file name consists of more than one word, it only shows the first word of the file name.

Here is the code,

while  ($name = readdir ($handle)) 
        {
            if ($name == '.' || $name == '..')
            continue; /* don't echo anything, skip to next read */
            $i++;
            echo '<td >';
            echo '<form name="form" method="get" action="download.php">';
            echo '<input type="hidden" name="file" value='.$name.' />';
            $parts=explode(".",$name);
            $name=$parts[0];
            echo '<input type="submit" name="submit" value='.$name.' class="subbutton" /> </br></br>';
            echo '</form>';
            echo '</td>';
            if($i==5)
            {
            echo '</tr>';
            echo '<tr>';
            $i=0;
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:10:59+00:00Added an answer on June 11, 2026 at 6:10 am

    Change this line:

    echo '<input type="submit" name="submit" value='.$name.' class="subbutton" /> </br></br>';
    

    to this:

    echo '<input type="submit" name="submit" value="'.$name.'" class="subbutton" /> </br></br>';
    

    That way you’re quoting your attribute and the HTML parser can’t get confused by spaces in your filenames.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a small function, which uses ElementTree to parse xml file,but it
I have written a small chat app that uses mysql + php to facilitate
I have written a small PHP file that gets the information that was posted
I have a small application written in PHP and a mysql database hosted on
I have written a small PHP framework and I want to make a website
I have a PHP script which works fine in PHP 5, but not in
I have written a simple database driven app in C# which uses a 2
I have written a small app that uses curl a while ago and was
I have written a app in PHP on my localhost server using XAMP, which
I have written a small webservice[Axis2/Java] which exposes a method public String Fill(String cacheName

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.