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