【发布时间】:2019-05-22 20:07:56
【问题描述】:
我想要从我的电脑中选择并打开一个 .txt 文件到一个数组中。我可以很容易地做到这一点;
$arr = explode("\n", file_get_contents('sampledata.txt'));
但我想用一个按钮来做。
<input type="file" name="my_file">
我可以使用该按钮选择文件,但我不知道如何创建数组。我将使用文本文件 ($arr) 中的数字进行 php 计算。这是可能的还是我在做梦?
谢谢。
【问题讨论】:
-
它上传到一个临时目录,您可以在
$_FILESphp.net/manual/en/features.file-upload.post-method.php 中获得详细信息,另外,只需使用file('sampledata.txt');