Strangeplant
08-26-2008, 04:00 PM
I need to have a column of check boxes for a column of files. When some of the boxes are checked and the user submits, an array of file names is returned. I will then zip the files and force download of the zipped file.
As an alternate method, the user may just click on a link and a single file will be forced downloaded, and that works fine too. I have all of the parts working with the exception of the returned array - I just can't figure it out even though I know it's done all the time (as on webmail deletes, among others). I seem to be missing something from the online examples. The array needs to be transmitted as a POST. So far, the form code (which is auto generated by the php script) looks like this:
foreach($files as $file => $timestamp){
echo ('<tr><td><input type="checkbox" name="filelist[]" value="' . $file . '"><a href="?file=' . $file . '">' . $file . '</a></td><td></td><td>');
$filesize = filesize($file);
if($filesize >= 1048576){
echo round($filesize / 1048576, 1).'MB';
} else {
echo round($filesize / 1024, 1).'kb';
}
echo '</td><td></td><td>'.date('M d Y H:i:s', $timestamp)."</td></tr>\n";
}
Meanwhile, near the top of my script, I have the this:
if(@$_POST['submit1'] == 'Submit'){
$type = $_POST['downloadmethod'];
$list = $_POST['filelist'];
$name = date('YmdHis');
$name .= $user;
$data = create_archive($name, $list, $type);
f_download($data);
} The problem is that $list does not contain the array of files checked.....What am I missing? I'd appreciate your help on this one.
As an alternate method, the user may just click on a link and a single file will be forced downloaded, and that works fine too. I have all of the parts working with the exception of the returned array - I just can't figure it out even though I know it's done all the time (as on webmail deletes, among others). I seem to be missing something from the online examples. The array needs to be transmitted as a POST. So far, the form code (which is auto generated by the php script) looks like this:
foreach($files as $file => $timestamp){
echo ('<tr><td><input type="checkbox" name="filelist[]" value="' . $file . '"><a href="?file=' . $file . '">' . $file . '</a></td><td></td><td>');
$filesize = filesize($file);
if($filesize >= 1048576){
echo round($filesize / 1048576, 1).'MB';
} else {
echo round($filesize / 1024, 1).'kb';
}
echo '</td><td></td><td>'.date('M d Y H:i:s', $timestamp)."</td></tr>\n";
}
Meanwhile, near the top of my script, I have the this:
if(@$_POST['submit1'] == 'Submit'){
$type = $_POST['downloadmethod'];
$list = $_POST['filelist'];
$name = date('YmdHis');
$name .= $user;
$data = create_archive($name, $list, $type);
f_download($data);
} The problem is that $list does not contain the array of files checked.....What am I missing? I'd appreciate your help on this one.