我正在尝试将图像上传到特定目录,但该功能moveTo并未移动图像。
public function uploadRecipeImageAction() {
if ($this->request->hasFiles() == true) {
$file = $this->request->getUploadedFiles()[0];
$target_file = '/uploads/ketogenic-recipes/'.preg_replace("/[^a-z0-9\_\-\.]/i", '', basename($file->getName()));
$file->moveTo($_SERVER['DOCUMENT_ROOT'] . $target_file);
}
return $target_file;
}
该功能在本地运行良好,但在服务器中不起作用。日志中没有错误
uploads和ketogenic-recipes目录权限设置为0775
PHP 版本7.2.20
Phalcon 版本是3.4
var_dump($_SERVER['DOCUMENT_ROOT']) = string(30) "/home/web/public_html/test2"
var_dump($target_file); = string(42) "/uploads/ketogenic-recipes/harrypotter.jpg"
繁星点点滴滴
泛舟湖上清波郎朗