file_get_contents():在C:examplep行中,文件名不能为空


file_get_contents(): Filename cannot be empty in line C: xampp

在谈到这一点之前,我想指出的是,我是一个PHP新手,在最终决定不知道我在用做什么之前,我已经为此奋斗了一段时间

function extract_bin($Filename, $output){
    global $template;
    global $BinColumnDelimiter;
    global $BinLineEnd;
    $decodedfile = fopen($output,'w+');
    $decodedfilecontents  = "";
    $handle = fopen($Filename, "r");
    if ($handle) {
        foreach ( $template as $ColName=>$Endians) 
            $decodedfilecontents .= $ColName.$BinColumnDelimiter;
        $decodedfilecontents .= $BinLineEnd;
        while (!feof($handle)) {
            $lastLine = '';
            foreach ($template as $ColName => $Endians){
                $hex  = bin2hex(fread($handle,$Endians));
                if ( $Endians <= 4) {
                    $val = hexdec(decodehex($hex));
                    if ( $val == 4294967295  ) $val = -1;
                    $lastLine .= $val.$BinColumnDelimiter;
                } else {
                    $lastLine .= str_replace("'t"," ",hex2str($hex)).$BinColumnDelimiter;
                }
            }
            if ( ! feof($handle))
                $decodedfilecontents .= $lastLine.$BinLineEnd;
        }
        fclose($handle);
        fwrite($decodedfile,$decodedfilecontents);
        fclose($decodedfile);
  }
  echo '<h1>'.$output.'</h1>';
  echo '<hr />';
  print_r($decodedfilecontents);
}

我一直收到这个错误:

警告:在第8行的C:''examplep''htdocs''rh-bin''func.php中,fopen():文件名不能为空

我的问题是,我试图将上传的文件作为附件传递,我做错了什么?为什么$FileName看起来是空的?此外,并不是每个人都会上传文件,所以我如何允许提交?

print_r($Filename)检查是否打印任何

在传递到fopen()之前检查$Filename是否为空。//这是很好的做法。

根据你的问题,你说不是每个人都在上传文件,然后你每次在不上传文件的情况下用空值调用这个函数,也要检查并确保这一点。