我想上传文件并使用 SFTP 保存。
这是我的代码:
if ($size != 0) {
$name = $uploadedFile->getClientOriginalName();
$extension = $uploadedFile->getClientMimeType();
$extension = \explode('.', $name);
$shortName = $extension[0];
$extension = \end($extension);
$allowedExtension = "zip";
$compare = strcmp(strtolower($extension), $allowedExtension);
if ($compare == 0) {//les deux chaines sont égaux
$saveName = $name;
if (file_exists($target_path . $name))
$saveName = $shortName . $date . '.' . $extension;
/* modif le dossier sera déposé en SFTP*/
/* Connexion SFTP */
$connection = ssh2_connect('webhost01', 22); // acces inetrne
ssh2_auth_password($connection, 'fbh', 'F#Bh52.6');
$sftp = ssh2_sftp($connection);
/* Déplacer le dossier dans le sftp */
ssh2_scp_send($connection,$saveName, '/home/fbh/newdir/', 0677);
}
但我收到此错误 ssh2_scp_send(12100102430010813_192636.zip) [function.ssh2-scp-send]: failed to open stream: No such file or directory。任何帮助请