public function editSave($data) { if (isset($data['article_img'])) { $imgUploader = new FileUpload($data['article_img']['name'], $data['article_img']['tmp_name']); $l_sNewFileName = $imgUploader->image(ROOT . '/public/assets/product/'); $imgUploader->image(ROOT . '/public/assets/product/thumb/', 218, 129, $data['cropped'][0], $data['cropped'][1], $data['cropped'][2], $data['cropped'][3]); $this->db->update('article', array('article_name' => $data['article_name'], 'article_price' => $data['article_price'], 'article_date' => $data['article_date'], 'category_id' => $data['category_id'], 'article_featured' => $data['article_featured'], 'artist_id' => $data['artist_id'], 'article_description' => $data['article_description'], 'article_img' => $l_sNewFileName), "article_id = {$data['article_id']}"); } else { $this->db->update('article', array('article_name' => $data['article_name'], 'article_price' => $data['article_price'], 'article_date' => $data['article_date'], 'category_id' => $data['category_id'], 'article_featured' => $data['article_featured'], 'artist_id' => $data['artist_id'], 'article_description' => $data['article_description']), "article_id = {$data['article_id']}"); } }
public function edit($data) { if (isset($data['artist_image'])) { $imgUploader = new FileUpload($data['artist_image']['name'], $data['artist_image']['tmp_name']); $l_sNewFileName = $imgUploader->image(ROOT . '/public/assets/artist/'); $imgUploader->image(ROOT . '/public/assets/artist/thumb/', 275, 322, $data['cropped'][0], $data['cropped'][1], $data['cropped'][2], $data['cropped'][3]); $this->db->update('artist', array('artist_name' => $data['artist_name'], 'artist_active' => $data['artist_active'], 'artist_website' => $data['artist_website'], 'artist_featured' => $data['artist_featured'], 'artist_country' => $data['artist_country'], 'artist_description' => $data['artist_description'], 'artist_image' => $l_sNewFileName), "artist_id = {$data['artist_id']}"); } else { $this->db->update('artist', array('artist_name' => $data['artist_name'], 'artist_active' => $data['artist_active'], 'artist_website' => $data['artist_website'], 'artist_featured' => $data['artist_featured'], 'artist_country' => $data['artist_country'], 'artist_description' => $data['artist_description']), "artist_id = {$data['artist_id']}"); } }
public function edit($data) { $dataArray = array('event_name' => $data['event_name'], 'event_date' => $data['event_date'], 'event_date_end' => $data['event_date_end'], 'event_description' => $data['event_description']); if (isset($data['event_image']) || isset($data['event_file'])) { if (isset($data['event_image'])) { $imgUploader = new FileUpload($data['event_image']['name'], $data['event_image']['tmp_name']); $l_sNewFileName = $imgUploader->image(ROOT . '/public/assets/event/'); $imgUploader->image(ROOT . '/public/assets/event/thumb/', 275, 163, $data['cropped'][0], $data['cropped'][1], $data['cropped'][2], $data['cropped'][3]); $dataArray['event_image'] = $l_sNewFileName; } if (isset($data['event_file'])) { $fileUploader = new FileUpload($data['event_file']['name'], $data['event_file']['tmp_name']); $l_sNewFileName = $fileUploader->file(ROOT . '/public/assets/file/'); $dataArray['event_file'] = $l_sNewFileName; } $this->db->update('event', $dataArray, "event_id = {$data['event_id']}"); } else { $this->db->update('event', $dataArray, "event_id = {$data['event_id']}"); } }
<?php require 'FileUpload.php'; function responeJson($obj) { header('Content-Type: application/json'); echo json_encode($obj); } $path = 'img/users/'; $fileuploader = new FileUpload('../' . $path); $fileuploader->image('fileUpload'); // print_r($fileuploader->getInfo()); // print_r($fileuploader->getMessage()); $result = array('fileInfo' => $fileuploader->getInfo(), 'errorMessage' => $fileuploader->getMessage(), 'filepath' => $path . $fileuploader->getInfo()['name']); return responeJson($result);
public function create($data) { $imgUploader = new FileUpload($data['slider_img']['name'], $data['slider_img']['tmp_name']); $l_sNewFileName = $imgUploader->image(ROOT . '/public/assets/slider/'); $l_aLowestOrder = $this->sliderAll(array('sort' => 'slider_order', 'order' => 'desc', 0, 1)); $l_nNewOrder = $l_aLowestOrder[0]['slider_order'] + 1; $this->db->insert('slider', array('slider_name' => $data['slider_name'], 'slider_type' => $data['slider_type'], 'slider_target' => $data['slider_target'], 'slider_order' => $l_nNewOrder, 'slider_img' => $l_sNewFileName)); }