Php 检查shell服务器中是否没有文件
我想从shell服务器下载文件,但若该文件在shell服务器中并没有,它将向并没有该文件的用户显示Php 检查shell服务器中是否没有文件,php,shell,get,phpseclib,downloadfile,Php,Shell,Get,Phpseclib,Downloadfile,我想从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 cla
<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>
我使用phpseclib,请建议我该怎么做。你可以做$sftp->file\u存在$txtdownload
$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
}