HTML表单的PHP Scandir函数(复选框) [英] PHP Scandir Function with HTML Form (Checkboxes)
问题描述
我有一个目录,其中包含各种文件,.txt,.xls,.pdf等
I have a directory that contains various files, .txt, .xls, .pdf, etc
我希望能够制作一个使用scandir函数来获取特定文件夹中每个文件的文件名的PHP脚本,将它们放入数组中,然后将其传递给HTML,以便将每个文件显示为一个可检查的框.
I would like to be able to make a PHP script that uses the scandir function to fetch the filenames of every file in a particular folder, put them in an array and then pass that off to HTML so that it displays each file as a check-able box.
这个想法是,用户访问网页,选中他/她希望打开的文件,然后点击提交按钮.每个文件都会打开(或者很可能会提示运行/保存,这很好).
The idea is that the user visits the web page, checkmarks the files he/she wishes to open and then hits a submit button. Each file will open up (or will most likely prompt to be run/saved, which is fine).
做到这一点的最佳方法是什么?
What is the best way to do this?
推荐答案
$files = scandir("./");
foreach ($files as $filename)
echo "<input type=\"checkbox\" name="files[]" value="{$filename}" /> {$filename}";
这篇关于HTML表单的PHP Scandir函数(复选框)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!