Answer the question
In order to leave comments, you need to log in
Action for uploading photos, framework, how to upload 2 or more photos at once?
Hello.
Those who know php and frameworks, tell me how to upload 2 or more photos.
I think the essence does not have any framework, but in general ko7, kohana.
My action for uploading and displaying all uploaded photos in the template.
public function action_index()
{
$id = (int)$this->request->param('id');
$fotogalerejas = ORM::factory('Fotogalereja')
->order_by('id', 'DESC')
->find_all();
if (isset($_POST['submit']))
{
$fotogalerejas = ORM::factory('Fotogalereja');
try
{
$fotogalerejas->save();
$id = $fotogalerejas->pk();
if (!empty($_FILES['images']['name'][0]))
{
foreach ($_FILES['images']['tmp_name'] as $i => $image)
{
$filename = $this->_upload_img($image);
$im_db = ORM::factory('Image');
$im_db->fotogalereja_id = $fotogalerejas->pk();
if (!empty($filename))
{
$im_db->image = $filename;
$im_db->save();
}
$p_db = ORM::factory('Fotogalereja', $fotogalerejas->pk());
if ($p_db->image_id == 0) {
$p_db->image_id = $im_db->pk();
$p_db->save();
}
}
}
$this->redirect('admin/fotogalereja/');
}
catch (ORM_Validation_Exception $e)
{
$errors = $e->errors('validation');
}
}
$content = View::factory('admin/fotogalereja/index')
->bind('errors', $errors)
->bind('id', $id)
->bind('fotogalerejas', $fotogalerejas);
$this->template->page_title = 'Фотогалерея';
$this->template->content = $content;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question