【问题标题】:Unable to save File to database from front end form in SilverStripe 4无法将文件从 SilverStripe 4 中的前端表单保存到数据库
【发布时间】:2016-09-20 07:24:25
【问题描述】:

我有一个通过 ajax 将数据发布到控制器的表单。

// Create new upload instance
$upload = Upload::create();

// Create new file instance
$file = File::create();

// Upload the file
$upload->loadIntoFile($fileData, $file, $this->folderName);

// Get the file from the Upload
$uploadedFile = $upload->getFile();

// Get the file from the Upload
$write = $uploadedFile->write();

图片上传成功,但文件未写入文件表。

没有错误报告。

【问题讨论】:

  • 这可能更适合SilverStripe issue tracker,因为 4.x 仍处于 alpha 阶段
  • @RobbieAverill 是的,我认为这可能是我做错了,我在 SS3 上尝试过,并且文件写入正确。我在 repo 上记录了一个错误。
  • 我投票结束这个问题,因为它是关于 SilverStripe 4 的预稳定 alpha 版本

标签: silverstripe


【解决方案1】:

这可能是文件未发布的问题?你检查过FileFile_Live 表吗?可能相关讨论:https://github.com/silverstripe/silverstripe-framework/issues/6048

【讨论】:

  • 检查了FileFile_LiveFile 有大约 9 个条目,File_Live 有大约 90 个,所以看起来它们已经发布了。另外,我如何去发布文件?我在任何地方都没有看到这样的选项。
  • 不幸的是,文件发布尚未实现,它在我们下一个 alpha 版本的列表中:github.com/silverstripe/silverstripe-asset-admin/issues/169。现在,您需要在自己的代码中调用File->publish('Stage', 'Live')
猜你喜欢
  • 1970-01-01
  • 2018-09-16
  • 1970-01-01
  • 2014-08-07
  • 2017-01-07
  • 1970-01-01
  • 2011-02-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多