Zobrazenie obrazka z DB (blob)
- nettak2
- Člen | 19
Ahojte,
prosim o radu. Chcem si vytiahnut obrazok z DB (tmp_name BLOB).
nezobrazuje sa mi obrazok, vzdy ked dam pravym volbu otvorit odkaz tak mi
nezobrazi fotku iba
data:image/png;base64,data='.data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA......
Diky !
presenter:
public function renderGallery() {
$this->template->gallery = $this->model->getAllPhoto();
}
public function uploadFileFormSucceeded(Form $form, $values)
{
/** @var \Nette\Http\FileUpload */
$fileUpload = $form['subor']->getValue();
$name = $fileUpload->getName();
//$tmpName = $fileUpload->getTemporaryFile();
$file = $fileUpload->getContents();
$file = (string)$file;
//bdump($tmpName);
bdump($file);
if ($fileUpload->isOk()) {
$this->model->savePhoto($values,$name,$file);
}
bdump($fileUpload);
$this->flashMessage('Práve ste pridali fotografiu do Vašej galérie.');
$this->redirect("Administrator:gallery");
}
sablona:
{if !empty($gallery)}
<table class="table table-hover">
<tr><br />
<th>Fotka</th>
<th>Názov fotky</th>
<th>Popis</th>
<th>Názov suboru</th>
<th>Editovať</th>
<th>Zmazať</th>
<th>Viditeľnosť fotky</th>
<td></td>
<td></td>
</tr>
{foreach $gallery as $gal}
<tr>
<td><img height="30" width="30" src="data:image/png;base64,'.{$gal->tmp_name|dataStream}.'"/></td>
<td>{$gal->nazov}</td>
<td>{$gal->popis}</td>
<td>{$gal->subor}</td>
<td><a n:href="Administrator:editGalleryPhoto $gal->id" class="glyphicon glyphicon-wrench"></a></td>
<td><a n:href="Administrator:deletePhoto $gal->id" class="glyphicon glyphicon-trash"></a></td>
<td><a n:href="Administrator:" class="glyphicon glyphicon-eye-open"></a></td>{*glyphicon glyphicon-eye-close*}
</tr>
{/foreach}
</table>
{else}
Žiadne fotografie.
{/if}