我安裝了"burzum/file-storage": "^1.1"
並遵循文檔CakePHP的問:Burzum /文件存儲無法保存文件
添加到了bootstrap.php中:
use Cake\Event\EventManager;
use Burzum\FileStorage\FileStorageUtils;
use Burzum\FileStorage\Storage\StorageManager;
use Burzum\FileStorage\Event\LocalFileStorageListener;
StorageManager::config('Local', [
'adapterOptions' => [TMP, true],
'adapterClass' => '\Gaufrette\Adapter\Local',
'class' => '\Gaufrette\Filesystem'
]);
$listener = new LocalFileStorageListener();
EventManager::instance()->on($listener);
我有一個表叫評論並加入此從文檔
$this->hasOne('PdfFiles', [
'className' => 'Burzum/FileStorage.PdfFiles',
'foreignKey' => 'foreign_key',
'conditions' => [
'PdfFiles.model' => 'Comments'
]
]);
加入這種形式:
<?= $this->Form->create($comment, ['type' => 'file']) ?>
<fieldset>
<legend><?= __('Edit Comment') ?></legend>
<?php
echo $this->Form->file('pdf_files.file');
echo $this->Form->input('comment');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
添加表到我的數據庫
cake migrations migrate -p Burzum/FileStorage
當我發送的形式文件不會在數據庫中保存在TMP文件夾,而不是。
我嘗試堅持事件。我不想使用手動版本(這是順便說一句)。
我錯過了什麼?
問候 Sundypha
檢查你的php和CakePHP日誌文件。 「未保存」真的沒有意義,有助於追蹤問題。我敢打賭,有一個許可問題或類似的東西。您也可以通過事件偵聽器代碼調試以找出它沒有保存文件的位置。我知道這個插件工作的很好,所以它或多或少地取決於你找出爲什麼這些文件沒有保存在你的環境中。 – burzum
是的事件似乎不會觸發。在debugKit中它缺少事件和包含的文件。我怎樣才能啓用你的插件日誌記錄? – Sundypha
該插件不使用任何特殊日誌記錄,請閱讀http://book.cakephp.org/3.0/en/core-libraries/logging.html – burzum