Php 我的脚本没有读取*.txt文件

Php 我的脚本没有读取*.txt文件,php,Php,我有一个表格,它有两个值。一个是一个.txt文件,其中一些链接是硬编码的,另一个是一个包含url的文本字段。当我按submit时,它会获取该url并检查*.txt文件中的每个链接。希望你能理解我说的话,如果没有,请评论,我会澄清的。现在我有问题了。只有链接所在的文件不在我的服务器上,我的代码才会工作。我不知道如何处理这个问题。我已经完成了我的搜索,我也尝试了mysql,但这对我来说并不合适。我的剧本是这样的: Enter your file :<input type="file" name

我有一个表格,它有两个值。一个是一个.txt文件,其中一些链接是硬编码的,另一个是一个包含url的文本字段。当我按submit时,它会获取该url并检查*.txt文件中的每个链接。希望你能理解我说的话,如果没有,请评论,我会澄清的。现在我有问题了。只有链接所在的文件不在我的服务器上,我的代码才会工作。我不知道如何处理这个问题。我已经完成了我的搜索,我也尝试了mysql,但这对我来说并不合适。我的剧本是这样的:

Enter your file :<input type="file" name="ufile" />
Enter your site name :<input type="text" name="utext" />
<input type="submit" value="Check" />
$needle = $_POST['utext'];
$file = $_FILES['ufile'];
$new = file($file, FILE_IGNORE_EMPTY_LINES | FILE_SKIP_EMPTY_LINES);
$new = array_map('trim', $new);
echo 'Total entries are: '.count($new).'<br />';
$found = array();
$notfound = array();
foreach ($new as $check) {
    echo "<table border='1'><tr>";
    echo "<td>Processing</td> <td>", $check,"</td></tr>";
    $a = file_get_contents($check);
    if (strpos($a, $needle)) {
        echo "<td><font color='green'>Found:</font></td>";
        $found[] = $check;
    } else {
        echo "<td><font color='red'>Not Found</font></td>";
        $notfound[] = $check;
    }
    echo "</tr></table>";
}
echo "Matches ".count($found)."<br />";
echo "Not Matched ".count($notfound);
输入您的文件:
输入您的站点名称:
现在,我的php脚本如下:

Enter your file :<input type="file" name="ufile" />
Enter your site name :<input type="text" name="utext" />
<input type="submit" value="Check" />
$needle = $_POST['utext'];
$file = $_FILES['ufile'];
$new = file($file, FILE_IGNORE_EMPTY_LINES | FILE_SKIP_EMPTY_LINES);
$new = array_map('trim', $new);
echo 'Total entries are: '.count($new).'<br />';
$found = array();
$notfound = array();
foreach ($new as $check) {
    echo "<table border='1'><tr>";
    echo "<td>Processing</td> <td>", $check,"</td></tr>";
    $a = file_get_contents($check);
    if (strpos($a, $needle)) {
        echo "<td><font color='green'>Found:</font></td>";
        $found[] = $check;
    } else {
        echo "<td><font color='red'>Not Found</font></td>";
        $notfound[] = $check;
    }
    echo "</tr></table>";
}
echo "Matches ".count($found)."<br />";
echo "Not Matched ".count($notfound);
$needle=$\u POST['utext'];
$file=$_文件['ufile'];
$new=file($file,file_IGNORE_EMPTY_line | file_SKIP_EMPTY_line);
$new=数组映射($trim',$new);
echo“总条目为:”.count($new)。”
; $found=array(); $notfound=array(); foreach($new as$check){ 回声“; 回显“处理”、$check“; $a=文件获取内容($check); if(STRPO($a,$B)){ 回声“发现:”; $found[]=$check; }否则{ 回声“未找到”; $notfound[]=$check; } 回声“; } 回显“匹配项”。计数($found)。“
”; 回显“不匹配”。计数($notfound);
有什么理由让你一开始就不让PHP处理上传?这将清楚地表明
$\u文件['ufile']
数组,因此您的代码无法工作。如果确实要继续编写代码而不首先理解它,请替换:

$file = $_FILES['ufile'];


请澄清什么是“我的代码不工作…”意思只有当.txt文件在服务器上时,我的代码才能工作。如果不是,代码也将不起作用