File Presenter přestal vkládat soubory do databáze
- fanatik
- Člen | 3
Ahojte,
potřeboval bych poradit, jestli nevíte, proč mi nefunguje vkládání souboru do databáze, když mi to roky předtím fungovalo a najednou to přestalo. Za každou radu budu rád. Děkuji.
Viz:
public function uploadFormSucceeded($form): void {
$sub = $this->getParameter('id');
if (!isset($sub)) {
$sub = 0;
}
try {
foreach ($_FILES as $file) {
if ($file['error']) {
continue;
}
$file_value = explode('.', $file['name']);
$type = Strings::lower($file_value[1]);
$file_name = Strings::lower($file_value[0]) . '__' . date('y_m_d_h_i') . '__' . $this->user->id . '.' . $file_value[1];
copy($file['tmp_name'], FILES_DIR . '/' . $file_name);
//thumbs
if (in_array($type, ['jpg', 'png', 'gif'])) {
$image = Image::fromFile(FILES_DIR . '/' . $file_name);
$image->resize(1000, null, Image::SHRINK_ONLY);
$image->save(FILES_DIR . '/' . $file_name);
$thumb = Image::fromFile(FILES_DIR . '/' . $file_name);
$thumb->resize(250, null);
$thumb->save(FILES_DIR . '/thumbs/' . $file_name);
// pro gallerii
$thumb_filled = Image::fromFile(FILES_DIR . '/' . $file_name);
$thumb_filled->resize(250, 167, Image::EXACT);
$thumb_filled->save(FILES_DIR . '/thumbs_filled/' . $file_name);
}
$values = [
'name' => $file_value[0],
'file_name' => $file_name,
'link' => $this->getHttpRequest()->getUrl()->getBaseUrl() . 'upload/' . $file_name,
'type' => $type,
'sub' => $sub,
'who_added' => $this->user->id,
];
$this->database->table('bp_files_data')->insert($values);
}
} catch (\Exception $ex) {
}
}
>
>
>
Editoval fanatik (18. 12. 2019 12:46)