[英]Yii2 FTP File upload not working
I have used the yii2mod/yii2-ftp module for uploading FTP Upload. 我已使用yii2mod / yii2-ftp模块上传FTP Upload。 But its not uploading the temp file directly. 但是它没有直接上传临时文件。
$uploadPath='/'.ucfirst(Yii::$app->user->identity->district->district->district_name).'/'.'temp/'.$model->quick_string;
///district/temp/1508159604x16 this my upload folder
if ($FtpClient->mkdir($uploadPath)){
$source_directory=$model->file->tempName;
$target_directory=$uploadPath.'/'.$model->file->name;
if($FtpClient->putAll($source_directory, $target_directory,FTP_BINARY)){
echo "success";exit;
}
}
output returned the error 输出返回错误
"dir(/tmp/phpizYNd7): failed to open dir: Not a directory" “ dir(/ tmp / phpizYNd7):无法打开dir:不是目录”
In yii2mod/yii2-ftp putAll Method Consider as a Directory.So the file could not possible to upload.Check the arguments is file or folder inside the function. 在yii2mod / yii2-ftp中,putAll方法考虑为目录。因此无法上传文件。检查参数是否为函数内的文件或文件夹。
Vendor/yii2mod/yii2-ftp/ftpClient.php Line 606 供应商/yii2mod/yii2-ftp/ftpClient.php行606
public function putAll($source_directory, $target_directory, $mode = FTP_BINARY)
{
if(is_dir($source_directory)){
$d = dir($source_directory);
// do this for each file in the directory
while ($file = $d->read()) {
// to prevent an infinite loop
if ($file != '.' && $file != '..') {
// do the following if it is a directory
if (is_dir($source_directory . '/' . $file)) {
if (!@$this->ftp->chdir($target_directory . '/' . $file)) {
// create directories that do not yet exist
$this->ftp->mkdir($target_directory . '/' . $file);
}
// recursive part
$this->putAll(
$source_directory . '/' . $file, $target_directory . '/' . $file,
$mode
);
} else {
// put the files
$this->ftp->put(
$target_directory . '/' . $file, $source_directory . '/' . $file,
$mode
);
}
}
}
}else{
$this->ftp->put(
$target_directory, $source_directory,
$mode
);
}
return $this;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.