【问题标题】:Check if file does not have in shell server检查shell服务器中是否没有文件
【发布时间】:2015-04-01 18:58:14
【问题描述】:

我想从 shell 服务器下载文件,但如果该文件在 shell 服务器中没有,它将显示给没有文件的用户

        <form class="cmxform form-horizontal tasi-form" name="frm" id="frm" method="post" enctype="multipart/form-data" action="loadfile.php" onsubmit="return validateForm();">
      <div class="form-group">
        <label class="col-sm-2 control-label">Full path of a file :</label>
        <div class="col-sm-5"><input type="text" class="form-control" name="download" required/></div>
          <input type="submit" id="submit" name="submit" class="btn btn-primary" value="Download" />
          <input type="reset" class="btn btn-danger" value="Cancel" />
        </div>
    </form>

我的加载文件是

$txtdownload = $_POST['download'];
$local_file = "report.txt"; //file name download
if($sftp->get($txtdownload,$local_file)){
header('Content-Length: '. filesize($local_file));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($local_file).'"');
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
readfile($local_file); // send the file
exit;  // make sure no extraneous characters get appended
}

我使用 phpseclib 请建议我该怎么做。

【问题讨论】:

    标签: php shell download get phpseclib


    【解决方案1】:

    你可以$sftp-&gt;file_exists($txtdownload)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-29
      • 1970-01-01
      • 1970-01-01
      • 2015-02-05
      • 2012-05-15
      • 1970-01-01
      相关资源
      最近更新 更多