Hi,
I am having a trouble here. Can anyone please help me. I have a menu list of many jpg files that are in my folder. After I choose the file and press submit, I wanted it to be downloaded. Can anyone out there please help me. Thanks
Regards.
Fernado
Download from Menu List
Moderator: General Moderators
Can you isolate a portion of code that isn't working as expected so we can help?
Perhaps the first thing to do when a form ain't working is add some debug lines to your script:
.. assuming the form method is POST (which it should be).
Perhaps the first thing to do when a form ain't working is add some debug lines to your script:
Code: Select all
<?php
echo '<pre>';
print_r($_POST);
echo '</pre>';
?>
Last edited by McGruff on Wed Aug 10, 2005 8:31 pm, edited 1 time in total.
-
fernado1283
- Forum Newbie
- Posts: 22
- Joined: Mon Aug 25, 2003 2:00 am
Hi,
This is what the code.
I can only open the file but I do not need to open the file but just only download the file when i click the submit button. Please help me. Thanks.
This is what the code.
I can only open the file but I do not need to open the file but just only download the file when i click the submit button. Please help me. Thanks.
Code: Select all
<?php
if (isset($actionflag) && $actionflag == "download")
{
$passing = $selectXYZ;
}
$file_array = array();
$file_array = getFiles($dir); // displays all the files in the folder
print "<form action="test.php " name="selection" target="_blank">";
print "<input type="hidden" name="actionflag" value="download">";
print "<select name="selectXYZ">";
foreach($file_array as $a_row)
{
// make sure it's not an include file or index file
if (!strstr($a_row,".inc.php") && !strstr($a_row,"index.php") && !strstr($a_row, ".php"))
{
if (!is_dir($a_row)) // the file is not a directory
{
print "<option>$a_row</option>";
}
}
}
print "</select> ";
print "<input type="submit">";
print "</form>";
?>
Regards
fernado
?>Take a look at the header() function http://uk.php.net/manual/en/function.header.php.
I would define a form action pointed at a form processor which downloads the file and displays an appropriate page.
I should also point out that this is something I've never got around to looking at in detail so far but I hope that helps.
I would define a form action pointed at a form processor which downloads the file and displays an appropriate page.
I should also point out that this is something I've never got around to looking at in detail so far but I hope that helps.