无法将文件上传到 phalcon 应用程序
Can't upload file to phalcon app
public function profilePictureAction()
{
// Check if the user has uploaded files
if ($this->request->hasFiles()) {
// Print the real file names and sizes
foreach ($this->request->getUploadedFiles() as $file) {
// Print file details
echo $file->getName(), " ", $file->getSize(), "\n";
// Move the file into the application
$file->moveTo('files/' . $file->getName());
}
}
}
以上是使用phalcon框架使用表单数据上传图片的代码。我已经用邮递员测试了这段代码,但有一个问题。
它的输出是 icon-testing.png 6773
图像名称和图像大小
但文件未上传到文件夹。
已经尝试使用我的 linux ubuntu /var/www/html/myapp/files 的完整路径
还是不能上传。
已经 chmod 755 文件夹
和 chown :www-data 和 chown my-username 那个 html 文件夹。
如果这是因为错误的权限,我想知道如何解决这个问题。
谢谢。
通过更改其他访问权限解决:可以创建和删除文件。
public function profilePictureAction()
{
// Check if the user has uploaded files
if ($this->request->hasFiles()) {
// Print the real file names and sizes
foreach ($this->request->getUploadedFiles() as $file) {
// Print file details
echo $file->getName(), " ", $file->getSize(), "\n";
// Move the file into the application
$file->moveTo('files/' . $file->getName());
}
}
}
以上是使用phalcon框架使用表单数据上传图片的代码。我已经用邮递员测试了这段代码,但有一个问题。 它的输出是 icon-testing.png 6773 图像名称和图像大小 但文件未上传到文件夹。 已经尝试使用我的 linux ubuntu /var/www/html/myapp/files 的完整路径 还是不能上传。 已经 chmod 755 文件夹 和 chown :www-data 和 chown my-username 那个 html 文件夹。 如果这是因为错误的权限,我想知道如何解决这个问题。 谢谢。
通过更改其他访问权限解决:可以创建和删除文件。