public function doPOST() { require DB_PATH . '/core/lib/image.php'; $img = new image($this->db); try { $img->upload($this->auth->authenticated()); redirect('view', $img->getentryid()); } catch (ImageException $e) { if ($e->rollback) { $img->rollback(); } $_SESSION['upload_errors'][] = $e->getMessage(); redirect('upload'); } }
public function submit() { $post = $_POST; $file = $_FILES['file_upload']; $request = new post($post, $file); $submission = $request->getPost(); $database = new database(); $query = $database->query(); $image = new image($query, $submission); // upload image try { $upload = $image->upload(); } catch (Exception $e) { echo 'Message: ' . $e->getMessage(); } // insert image if (isset($upload) && $upload == 'success') { $images = new image($query, $submission); $image->insert(); } }
$ext = strrchr($_FILES["photo"]['name'][$key], "."); $ran_num = (time() | 0) . "_" . rand(0, 999999999); $output_path = "../../gallery_activity/"; $file_name = $id . "_{$ran_num}.png"; $ori_file_name = $id . "_{$ran_num}{$ext}"; // $size = GetImageSize($upfile); // copy($upfile,$output_path.$file_name); // image_resize( $upfile, $output_filename, $output_path, 190, 120); // // copy($upfile,$output_path."small/".$file_name); // image_resize( $upfile, $output_filename, $output_path, 90, 60); // copy( $upfile, $output_path."original/".$ori_file_name ); $image = (require_once "../../include/image.class.php"); $image = new image(); $image->source = $_FILES['photo']["tmp_name"][$key]; $image->allow_size = 5; $image->save_path = "../../gallery_activity/"; $image->save_name = $ori_file_name; if ($image->upload()) { // mysql_query("INSERT INTO tbl_file_attachment (`file_id`, `url`) value({$last_insert_id}, '{$filename}');"); $image->create_img(190, 120, 0, NULL, "web"); $image->create_img(90, 60, 0, NULL, "thumb"); } $sql_c = "INSERT INTO `tbl_activity_gallery` ( `act_id`, `file_name`, `ori_file_name`, `remark`, `g_order` ) VALUES ('{$id}', '{$ori_file_name}', '{$ori_file_name}', '{$remark}', {$g_order} )"; mysql_query("set names utf8"); mysql_query($sql_c, $link_id); } } ////////////////////////////////////////////////////////////////////////////////////////////////////// /* End Upload Photo */ ////////////////////////////////////////////////////////////////////////////////////////////////////// mysql_close();
// require_once("../../include/image.class.php"); $id = $_POST[id] | 0; foreach ($_FILES["photo"]["error"] as $key => $error) { if ($error == 0) { $upfile = $_FILES["photo"]["tmp_name"][$key]; $remark = EncodeHTMLTag($_POST["remark"][$key]); $g_order = $_POST["order"][$key] | 0; $ext = strrchr($_FILES["photo"]['name'][$key], "."); $ran_num = (time() | 0) . "_" . rand(0, 999999999); $output_path = "../../gallery_activity/"; $file_name = $id . "_{$ran_num}.png"; $ori_file_name = $id . "_{$ran_num}{$ext}"; $image = (require_once "../../include/image.class.php"); $image = new image(); $image->source = $_FILES['photo']["tmp_name"][$key]; $image->allow_size = 5; $image->save_path = "../../gallery_activity/"; $image->save_name = $ori_file_name; $image->upload(); $image->create_img(190, 120, 0, NULL, "web"); $image->create_img(90, 60, 0, NULL, "thumb"); $sql_c = "INSERT INTO `tbl_lastest_gallery` ( `act_id`, `file_name`, `ori_file_name`, `remark`, `g_order` ) VALUES ('{$id}', '{$ori_file_name}', '{$ori_file_name}', '{$remark}', {$g_order} )"; mysql_query("set names utf8"); mysql_query($sql_c, $link_id); } } ////////////////////////////////////////////////////////////////////////////////////////////////////// /* End Upload Photo */ ////////////////////////////////////////////////////////////////////////////////////////////////////// mysql_close(); header("location:gallery.php?id={$_POST['id']}");
$telp_kantor = $form->input('telp_kantor'); $faksimil = $form->input('faksimil'); $email = $form->input('email'); $action = $form->input('action'); $user = $_SESSION['nama']; $date = date('Y-m-d H:i:s'); // START INSERT DATA ==============================> if ($action == "insert") { $foto = $_FILES['foto']['name']; $id = $number->id('anggota', 5); $kta_baru = $number->kta($desa_id, $tgl_lahir, $id); if (empty($foto)) { $foto = "user.png"; } else { $source = $_FILES['foto']['tmp_name']; $image->upload($foto, $source); $image->thumbnail($foto); } $sql = "INSERT INTO anggota\n (id,nama, id_tipe, id_no, jabatan, tempat, tgl_lahir, jns_kelamin, agama,\n pernikahan, pekerjaan_id, pendidikan, alamat, rt, rw, propinsi_id, kota_id, kecamatan_id,\n desa_id, hp, telp_rumah, telp_kantor, faksimil, email, foto, kta_baru, aktif, crt, crt_date) \n VALUES \n ('{$id}','{$nama}','{$id_tipe}','{$id_no}','{$jabatan}','{$tempat}','{$tgl_lahir}','{$jns_kelamin}','{$agama}',\n '{$pernikahan}','{$pekerjaan_id}','{$pendidikan}','{$alamat}','{$rt}','{$rw}','{$propinsi_id}','{$kota_id}','{$kecamatan_id}',\n '{$desa_id}','{$hp}','{$telp_rumah}','{$telp_kantor}','{$faksimil}','{$email}','{$foto}','{$kta_baru}','{$aktif}','{$user}','{$date}')"; if (!$database->query($sql)) { die($sql); } else { $_SESSION['success'] = "<b>Berhasil!</b> Anda telah menambahkan data baru"; header("Location: create.php"); exit; } } // END INSERT DATA ==============================> // START UPDATE DATA ==============================> if ($action == "update") { $id = $form->input('id');