/** * 修改之前的操作 * 在修改操作之前先判断是否有图片上传, * 有图片上传则删掉之前的图片,保存新的图片; * 没有图片上传则保留原来的图片 */ protected function _before_update(&$data, $options) { //判断是否有图片上传 if (!empty($_FILES['bg_imgpath']['name'])) { //获取修改的数据id $bg_id = $options['where']['bg_id']; //获取改数据的图片路径,并判断是否存在,存在则删除 $img_path = $this->field('bg_imgpath')->where(array('bg_id' => $bg_id))->find(); if ($img_path['bg_imgpath']) { $path = C('rootPath') . $img_path['bg_imgpath']; //拼接图片所在的位置 @unlink($path); //unlink:删除文件的函数 @防止报错 } //图片上传操作 $config = array('mimes' => array('image/jpg', 'image/png', 'image/jpeg', 'image/gif'), 'rootPath' => C('rootPath'), 'maxSize' => 0, 'savePath' => 'Blog/', 'is_array' => 0); //执行上传文件和生成缩略图的操作 $res = uploadImage('bg_imgpath', $config); //判断上述操作是否执行成功 if ($res['ok'] == 1) { //将源图和缩略图的地址存放$data数组中写入数据库 $data['bg_imgpath'] = $res['img'][0]; } else { //返回上传文件和生成缩略图中产生的错误 $this->error = $res['error']; return false; } } }
function addToBook() { //set all of the variables $address_group_id = filter_input(INPUT_POST, 'address_group_id'); $fullname = filter_input(INPUT_POST, 'fullname'); $email = filter_input(INPUT_POST, 'email'); $address = filter_input(INPUT_POST, 'address'); $phone = filter_input(INPUT_POST, 'phone'); $website = filter_input(INPUT_POST, 'website'); $birthday = filter_input(INPUT_POST, 'birthday'); //replace the phone number with the appropriate formatting $phoneRegex = '/^\\(?([2-9]{1}[0-9]{2})\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/'; $phone = preg_replace($phoneRegex, '($1) $2-$3', $phone); if (strlen($fullname) < 1 || strlen($email) < 1 || strlen($address) < 1 || strlen($phone) < 1) { return false; } try { $image = uploadImage('upfile'); } catch (RuntimeException $ex) { //echo $ex->getMessage(); $image = ''; } //connect and set statement $db = dbconnect(); $stmt = $db->prepare("INSERT INTO address SET user_id = :user_id, address_group_id = :address_group_id, fullname = :fullname, email = :email, address = :address, phone = :phone, website = :website, birthday = :birthday, image = :image"); $binds = array(":user_id" => $_SESSION['user_id'], ":address_group_id" => $address_group_id, ":fullname" => $fullname, ":email" => $email, ":address" => $address, ":phone" => $phone, ":website" => $website, ":birthday" => $birthday, ":image" => $image); if ($stmt->execute($binds) && $stmt->rowCount() > 0) { return true; } else { return false; } }
public function update($postData, $book_id, $target_dir) { if (uploadImage($target_dir) !== 'success' && uploadImage($target_dir) !== 'Image is not chosen.') { return uploadImage($target_dir); } else { $postData['image'] = basename($_FILES["image"]["name"]); if ($postData['image'] === '') { $postData['image'] = $_SESSION['oldImage']; } db_update($this->table, $postData, 'id=' . $book_id); return 'success'; } }
/** * Fonction permettant d'ajouter une activité en base de données grâce aux données d'un formulaire. * @return mixed : soit un tableau contenant tous les messages d'erreurs relatif à l'ajout d'activité, soit un tableau * contenant un message de succès de l'ajout de l'activité. */ function ajouterActivite() { $cat = $_POST['categorie']; $act = $_POST['activite']; $desc = $_POST['description']; $cm = new CategorieManager(connexionDb()); $am = new ActivityManager(connexionDb()); $categorie = $cm->getCategorieByLibelle($cat); $activityVerif = $am->getActivityByLibelle($act); if (strtolower($activityVerif->getLibelle()) == strtolower($act)) { $tabRetour['Error'] = "Cette activité existe déjà, ajoutez-en une autre !"; } else { if (strlen($act) >= 5 && strlen($act) <= 100) { if (champsTexteValable($desc)) { $desc = nl2br($desc); $activityToAdd = new Activity(array("Libelle" => $act, "description" => $desc)); $am->addActivity($activityToAdd); $activityToRecup = $am->getActivityByLibelle($act); include "../Manager/Categorie_ActivityManager.manager.php"; $typePhoto = $_FILES['image']['type']; if (!strstr($typePhoto, 'jpg') && !strstr($typePhoto, 'jpeg')) { $tabRetour['Error'] = "Votre image n'est pas .jpg ou .jpeg !"; } else { if ($_FILES['ImageNews']['size'] >= 2097152) { $tabRetour['Error'] = "Votre image est trop lourde !"; } else { if ($_FILES['image']['tmp_name'] != null) { uploadImage('../Images/activite', $activityToRecup->getId()); $cam = new Categorie_ActivityManager(connexionDb()); $um = new UserManager(connexionDb()); $um->updateUserLastIdea($_SESSION['User']); $cam->addToTable($activityToRecup, $categorie); $tabRetour['Ok'] = "Votre activité a bien été ajoutée au contenu du site, merci de votre participation !"; } else { $tabRetour['Error'] = "Pas d'image !"; } } } } else { $tabRetour['Error'] = "Votre description contient des caractères indésirables !"; } } else { $tabRetour['Error'] = "Votre titre d'activité n'a pas une taille correcte !"; } } return $tabRetour; }
function insertNewMeal($values, $connectionObject) { $fileName = uploadImage("mealPicture", "content/pictures/"); if ($fileName) { $createMealQuery = "INSERT INTO meal VALUES (DEFAULT, :name_, :price, :quantity, :snack, :drink, :picture)"; $createMealResult = $connectionObject->prepare($createMealQuery); $createMealResult->execute(array(':name_' => $values['newMealName'], ':price' => $values['newMealPrice'], ':quantity' => $values['newMealQuantity'], ':snack' => $values['newMealSnack'], ':drink' => $values['newMealDrink'], ':picture' => $fileName)); if (!$createMealResult) { echo "An error occurred.\n"; error_log("Error on insertNewMeal function"); return Null; } } else { echo "Error uploading image"; error_log("Error uploading image"); } }
public function index() { $amount = (int) $this->input->get('amount'); $imagesArray = $this->Image->getImages(0, $amount); foreach ($imagesArray as $key => $value) { if (file_exists($this->config->item('PATH_IMAGE') . $value->image)) { $pathImage = $this->config->item('PATH_IMAGE') . $value->image; $result = uploadImage(['PATH_IMAGE' => $pathImage, 'PATH_COOKIE' => $this->config->item('PATH_COOKIE'), 'title' => $value->title]); sleep(30); unlink($pathImage); $this->Image->deleteImage($value->id); } } print_r($imagesArray); // $this->output // ->set_status_header($result['status']) // ->set_output(json_encode($result['data'])); }
function uploadImage($conf, $depth = 0) { $depth = (int) $depth; $depth = $depth + 1; $result = postingImage($conf); print_r($result); if ($result['status'] != 200 && $depth < 3) { // hack file_get_contents("http://localhost/instagram/index.php/GetCookie/"); return uploadImage($conf, $depth); } else { if ($result['status'] != 200 && $depth >= 3) { log_message('error', 'Don\'t upload Image'); // throw new Exception('Error'); } else { return $result; } } }
/** * @param null $id * Cette méthode permet d'editer et d'enregistrer, selon qu'on ait le ID ou pas */ public function admin_edit($id = null) { $this->loadModel('Offreancia'); //on charge le controller qu'on veut éditer $this->Offreancia->changeID(); $d['id'] = ''; if ($this->request->data) { //debug($_FILES['IMAGE']['name']); if (!empty($_FILES['IMAGE']['name'])) { $imageValid = uploadImage('IMAGE'); if ($imageValid['ok']) { $this->request->data->IMAGE = $imageValid['chemin']; // debug($this->request->data); // die(); } else { echo '<script>alert("' . $imageValid['msg'] . '")</script>'; } } if ($this->Offreancia->validates($this->request->data)) { if ($this->Offreancia->save($this->request->data)) { $this->Session->setFlash('le contenu a bien été modifié', 'success'); } // die($id=$this->Post->id); //echo("ajouté ou modifié"); } else { $this->Offreancia->save($this->request->data); $this->Session->setFlash('Merci de corriger vos informations', 'danger'); } } if ($id) { $id = intval($id); $this->request->data = $this->Offreancia->findOne(array('conditions' => array('ID_OFFRE_ANCIA' => $id))); $d['id'] = $id; } $this->loadModel('Utilisateur'); $this->Utilisateur->changeID(); $d['utilisateurs'] = $this->Utilisateur->find(array()); $this->loadModel('Client'); $this->Client->changeID(); $d['clients'] = $this->Client->find(array()); $this->set($d); }
function uploadPhoto($ip, $image, $nick, $email, $path, $albumName) { $existsAlbum = isAlbum($nick, $albumName); if (!$existsAlbum) { if (!newAlbum($ip, $nick, $email, $albumName, "private", "DEFAULT")) { return '1'; } } if (uploadImage($image, $path)) { $newPhoto = addPhoto($nick, $path, $albumName); if (!newPhoto and !$existsAlbum) { deleteAlbum($nick, $albumName); // Remove Photo return '2'; } addAction($nick, $email, $ip, 'new_photo'); return '0'; } return '3'; }
function modifyCategory() { $catId = (int) $_GET['catId']; $name = $_POST['txtName']; $description = $_POST['mtxDescription']; $image = $_FILES['fleImage']; $catImage = uploadImage('fleImage', SRV_ROOT . 'images/category/'); // if uploading a new image // remove old image if ($catImage != '') { _deleteImage($catId); $catImage = "'{$catImage}'"; } else { // leave the category image as it was $catImage = 'cat_image'; } $sql = "UPDATE tbl_category \n SET cat_name = '{$name}', cat_description = '{$description}', cat_image = {$catImage}\n WHERE cat_id = {$catId}"; $result = dbQuery($sql) or die('Cannot update category. ' . mysql_error()); header('Location: index.php'); }
function product_update() { $id = $_POST['id']; if (isset($_POST['update'])) { $data['product_object'] = model('product')->getOne($id); //var_dump($data);die; $data['template_file'] = 'product/update.php'; render('layout.php', $data); } if (isset($_POST['saveUpdate'])) { unset($_POST['saveUpdate']); $postData = postData(); if ($_FILES["fileImage"]['name'] != "") { $postData['image'] = uploadImage(); deleteImage($_POST['image']); } if (model('product')->updateProduct($postData, $id)) { redirect('/index.php?c=product&m=list'); } } }
mysql_select_db($database, $dbConn); $transaccion = $_POST['transaccion']; switch ($transaccion) { case 'INSERT': // Obtiene de la base de datos el último id de los celulares $query_newId = "SELECT (MAX(id_celular) + 1) as newId FROM celularesMasPopulares"; $newId = mysql_query($query_newId, $dbConn) or die(mysql_error()); $row_newId = mysql_fetch_assoc($newId); $id_celular = $row_newId["newId"]; $dir_celular = "../../uploads/celulares_mas_populares/" . $id_celular . "/"; $filename = NULL; if ($_FILES['foto']['tmp_name'] != NULL) { $filename = uploadImage("foto", $dir_celular, 120, 248); } $sql = sprintf("INSERT INTO celularesMasPopulares(id_celular, nombre, foto) VALUES(%s, %s, %s)", GetSQLValueString($id_celular, "int"), GetSQLValueString(utf8_decode($_POST['nombre']), "text"), GetSQLValueString($filename, "text")); echo "{$sql}"; break; case 'UPDATE': $dir_celular = "../../uploads/celulares_mas_populares/" . $_POST['id_celular'] . "/"; $filename = NULL; if ($_FILES['foto']['tmp_name'] != NULL) { $filename = uploadImage("foto", $dir_celular, 120, 248); } else { $filename = $_POST['foto_actual']; } $sql = sprintf("UPDATE celularesMasPopulares SET nombre=%s, foto=%s WHERE id_celular=%s", GetSQLValueString(utf8_decode($_POST['nombre']), "text"), GetSQLValueString($filename, "text"), GetSQLValueString($_POST['id_celular'], "int")); break; } // switch $result = mysql_query($sql, $dbConn) or die(mysql_error()); mysql_free_result($result);
<?php if (isset($_POST['sg'])) { if (!empty($_FILES['thumb']['tmp_name'])) { $pasta = "../upload/"; $ano = date('Y'); $mes = date('m'); if (!file_exists($pasta . $ano) && is_dir($pasta . $ano)) { mkdir($pasta . $ano, 0755); } if (!file_exists($pasta . $ano . '/' . $mes)) { mkdir($pasta . $ano . '/' . $mes, 0755); } $img = $_FILES['thumb']; $ext = substr($img['name'], -3); $thumb = $ano . '/' . $mes . '/' . setUri($img['name']); uploadImage($img['tmp_name'], setUri($img['name']), '600', $pasta . $ano . '/' . $mes . '/'); } $d = date('Y-m-d H:i:s'); $campos = array('post_id' => $postId, 'img' => $thumb, 'data' => $d); create("galeria", $campos); } ?> <?php // deleta imagem no bando e na pasta upload if (!empty($_GET['iddel'])) { $iddel = $_GET['iddel']; $img = $_GET['img']; $pasta = $pasta = "../upload/"; if (file_exists($pasta . $img)) { unlink($pasta . $img);
} elseif (!valMail($f['email'])) { echo '<span class="ms al">Atenção: O e-mail informado nao tem um formato válido!</span>'; } elseif (strlen($f['code']) < 8 || strlen($f['code']) > 12) { echo '<span class="ms no">Erro: A senha deve ter entre 8 e 12 caracteres!</span>'; } else { if (!empty($_FILES['avatar']['tmp_name'])) { $imagem = $_FILES['avatar']; $pasta = '../uploads/avatars/'; if (file_exists($pasta . $user['avatar']) && !is_dir($pasta . $user['avatar'])) { unlink($pasta . $user['avatar']); } $tmp = $imagem['tmp_name']; $ext = substr($imagem['name'], -3); $nome = md5(time()) . '.' . $ext; $f['avatar'] = $nome; uploadImage($tmp, $nome, 200, $pasta); } unset($f['date']); unset($f['statusS']); update('up_users', $f, "id = '{$userEditId}'"); $_SESSION['return'] = '<span class="ms ok">Usuário atualizado com sucesso!</span>'; header('Location: index2.php?exe=usuarios/usuarios-edit&userid=' . $userEditId); } } elseif (!empty($_SESSION['return'])) { echo $_SESSION['return']; unset($_SESSION['return']); } ?> <form name="formulario" action="" method="post" enctype="multipart/form-data"> <label class="line"> <span class="data">Nome:</span>
<?php $addressGroups = getAddressGroups(); $newAddressData = array(); if (isPostRequest()) { $newAddressData[0] = $_SESSION['currentUserID']; $newAddressData[1] = filter_input(INPUT_POST, 'selected_address_group'); $newAddressData[2] = filter_input(INPUT_POST, 'fullname'); $newAddressData[3] = filter_input(INPUT_POST, 'email'); $newAddressData[4] = filter_input(INPUT_POST, 'address'); $newAddressData[5] = formatPhone(stripPhone(filter_input(INPUT_POST, 'phone'))); $newAddressData[6] = filter_input(INPUT_POST, 'website'); $newAddressData[7] = filter_input(INPUT_POST, 'birthday'); $errors = validation($newAddressData); if (count($errors) == 0) { $newAddressData[8] = uploadImage(); if (empty($newAddressData[8])) { $errors[] = 'Image could not be uploaded'; $results = 'Empty Image'; } if (createContact($newAddressData)) { $results = 'New item added to address book'; } else { $results = 'Item was not Added'; } } else { $results = 'Errors found'; } } ?>
*/ if (checkSensorId($conn, $sensor_id) != 0) { return; } // date $date_created = $_POST['date_image']; // description $description = $_POST['desc_image']; // Image Type Check $imgType = $_FILES['file_image']['type']; if ($imgType != "image/jpeg") { echo "File Not Found/Extension not allowed, please choose a JPG file"; return; } // Upload Image uploadImage($conn, $sensor_id, $date_created, $description); } // ----Upload Scalar---- // separate a string by another string // http://php.net/manual/en/function.explode.php if (isset($_POST["submit_scalar"])) { $scalarType = $_FILES['file_scalar']['type']; if ($scalarType != "text/csv") { echo "File Not Found/Extension not allowed, please choose a csv file"; return; } $fp = fopen($_FILES['file_scalar']['tmp_name'], 'r'); /* while ( ($line = fgets($fp)) !== false) { echo $line."<br>"; $pieces = explode(",", $line);
<?php include 'includes/header.php'; $db = new Database(); $ca = new Category(); $pi = new Picture(); $categories = $db->select($ca->getAllCategories()); uploadImage(); ?> <h2 class="page-header">Add Image</h2> <div class="row"> <div class="col-md-10"> <form method="post" action="add_image.php" enctype="multipart/form-data"> <div class="form-group"> <label>Image Title</label> <input name="title" type="text" class="form-control" placeholder="Enter image title"> </div> <div class="form-group"> <label>Image Description</label> <textarea name="description" class="form-control" placeholder="Enter image description"></textarea> </div> <div class="col-md-5"> <label>Select image to upload:</label> <input type="file" name="image" id="image"> </div> <div class="col-md-5"> <div class="form-group"> <label>Year</label> <input name="year" type="number" class="form-control" placeholder="Enter estimated year"> </div>
<title></title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"> <title></title> </head> <body> <?php // Uploads Images of Products into DataBase include '../../functions/products-functions.php'; try { $uploadName = uploadImage('upfile'); echo $uploadName; } catch (Exception $e) { echo $e->getMessage(); } ?> <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="#" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <!-- <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> --> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="upfile" type="file" /> <input type="submit" value="Send File" /> </form>
return $itemID; } function tagImage($itemID) { global $hostname; $ch = curl_init(); $data = array('tagIDs' => implode("|", $_POST['options'])); curl_setopt($ch, CURLOPT_URL, "http://{$hostname}/api/taxonomy/tagItem/{$itemID}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Scitemwebapi-Username: sitecore\\admin', 'X-Scitemwebapi-Password: b')); $response = curl_exec($ch); } if (isset($_POST["submit"])) { $itemID = uploadImage(); tagImage($itemID); header("Location: /?done=1"); die; } ?> <!DOCTYPE html> <html> <head> <title>ARM PHP Asset Uploader</title> <script> var hostname = '<?php echo $hostname; ?> '; </script>
function addnow() { $adddate[0][1] = trim(filter_input(INPUT_POST, "fname"), " "); $adddate[1][1] = trim(filter_input(INPUT_POST, "lname"), " "); $adddate[2][1] = filter_input(INPUT_POST, "email"); $adddate[3][1] = filter_input(INPUT_POST, "addr"); $adddate[4][1] = filter_input(INPUT_POST, "tel"); $adddate[5][1] = filter_input(INPUT_POST, "url"); $adddate[6][1] = filter_input(INPUT_POST, "month"); $adddate[7][1] = filter_input(INPUT_POST, "group"); if ($adddate[0][1] == "") { echo "First Name Invaild"; return false; } if ($adddate[1][1] == "") { echo "Last Name Invaild"; return false; } if ($adddate[2][1] == "") { echo "Email is invaild"; return false; } if ($adddate[3][1] == "") { echo "Address is invaild"; return false; } if ($adddate[4][1] == "") { echo "Phone number is invaild"; return false; } if ($adddate[5][1] == "") { echo "Website is invaild"; return false; } if (filter_var($adddate[5][1], FILTER_VALIDATE_URL) === false) { echo "Website Not Vaild"; return false; } if ($adddate[6][1] == "") { echo "Birth day is invaild"; return false; } $adddate[8] = uploadImage(); $searchAll = getDatabase()->prepare("insert into address set user_id = :id,address_group_id = :group,fullname = :name, email = :email,address= :addr,phone = :phone,website = :web, birthday = :birthday, image = :image"); $binds = array(":id" => $_SESSION["theid"], ":group" => implode($adddate[7]), ":name" => implode($adddate[0]) . " " . implode($adddate[1]), ":email" => implode($adddate[2]), ":addr" => implode($adddate[3]), ":phone" => implode($adddate[4]), ":web" => implode($adddate[5]), ":birthday" => implode($adddate[6]), ":image" => $adddate[8]); if ($searchAll->execute($binds)) { return true; } else { return false; } }
if (isset($_POST['type']) && isset($_POST['name']) && isset($_POST['description']) && isset($_POST['date']) && isset($_FILES["image"]) && isset($_POST["csrf_token"])) { if (validateCSRFToken($_POST["csrf_token"])) { $extension = pathinfo($_FILES["image"]["name"], PATHINFO_EXTENSION); if (isset($extension)) { if (test_date($_POST['date'])) { $idEvent = createEvent($_POST['type'], $_POST['name'], $_POST['description'], $_POST['date'], isset($_POST['public']), $_SESSION['userid']); if ($idEvent != -1) { try { if (file_exists($_FILES['image']['tmp_name']) && is_uploaded_file($_FILES['image']['tmp_name'])) { // Check if an image was been uploaded $target_dir = "images/events/"; $target_file = $target_dir . $idEvent . '.' . $extension; if (!updateEventImage($idEvent, $target_file)) { throw new RuntimeException("Could not set event image."); } uploadImage($_FILES["image"], $target_file); } showSuccess("Event created."); } catch (RuntimeException $e) { showError($e->getMessage()); } } else { showError("Could not create the event."); } } else { showError("Invalid event date. Date must have format YYYY-MM-DD HH:MM(:SS)"); } } else { showError("Invalid file."); } } else {
if (DB::count() !== 0) { // valid if ($setting["value"] !== $value) { // change it DB::update("settings", array("value" => $value), "name=%s", $name); echo json_array(1, array("name" => $name, "value" => $value), "successfully changed"); return; } echo json_array(0, null, "no change made"); return; } echo json_array(0, null, "invalid setting"); return; } if ($type === "2") { $f = $_FILES['settingsfile']; $loc = uploadImage($f); if ($loc !== -1) { DB::update("settings", array("value" => $loc), "name=%s", $_POST["name"]); // echo json_array(0, null, "failure to upload file"); // return; } header("Location: /admin.php"); // echo json_array(1, array("newloc"=>$loc), "success!"); exit; } } echo json_array(0, $user->data["permission"], "invalid permissions"); return; } echo json_array(0, $_POST, "invalid user or data");
} else { $readUserMail = read('users', "WHERE email = '{$f['email']}'"); $readUserCpf = read('users', "WHERE cpf = '{$f['cpf']}'"); if ($readUserMail) { echo '<span class="alert alert-error" style="float:left;"> Erro : Já existe este E-mail cadastrado, informe outro E-mail!</span>'; } elseif ($readUserCpf) { echo '<span class="alert alert-error" style="float:left;"> Erro : Já existe este CPF cadastrado, informe outro CPF!</span>'; } else { if (!empty($_FILES['avatar']['tmp_name'])) { $imagem = $_FILES['avatar']; $pasta = '../uploads/avatars/'; $tmp = $imagem['tmp_name']; $ext = substr($imagem['name'], -3); $nome = md5(time()) . '.' . $ext; $f['avatar'] = $nome; uploadImage($tmp, $nome, '200', $pasta); } unset($f['date']); unset($f['statusS']); create('users', $f); echo '<span class="alert alert-success" style="float:left;">Usuário cadastrado com sucesso!</span>'; unset($f); } } } ?> <form name="formulario" action="" method="post" class="form-horizontal" enctype="multipart/form-data"> <fieldset> <legend>Cadastrar Usuário:</legend> <div class="control-group"> <label class="control-label" for="avatar"><span>Avatar:</span></label>
<?php include_once "database/events.php"; include_once "database/upload.php"; if (isset($_POST['create_btn'])) { $image_path = uploadImage($_FILES['image'], 'resources/images/uploaded/'); echo '<p> Final path: ' . $image_path; if ($image_path != 'error') { if ($_POST['private'] == 'yes') { $private = 1; } else { $private = 0; } createEvent($_POST['date'], $_POST['description'], $_POST['type'], $_POST['creator'], $image_path, $private); } } header('Location: ' . './list_events.php');
$stmt = $dbhelper->prepare("SELECT * FROM admin WHERE name = ? AND emailid = ? AND pass = ? AND pic = ?"); $stmt->bindParam('1', $fullname); $stmt->bindParam('2', $emailid); $stmt->bindParam('3', $cpass); $stmt->bindParam('4', $picture); $stmt->execute(); if ($result = $stmt->fetch(PDO::FETCH_ASSOC) && ($npass1 == "" && $npass2 == "")) { echo "Nothing Changed!"; } else { $stmt = $dbhelper->prepare("SELECT pass, pic FROM admin WHERE emailid = ?"); $stmt->bindParam('1', $emailid); $stmt->execute(); if ($result = $stmt->fetch(PDO::FETCH_ASSOC)) { if ($result['pass'] == $cpass) { if (isset($_FILES['fileToUpload'])) { $pic = uploadImage($picture); if ($pic != "") { $stmt = $dbhelper->prepare("UPDATE admin SET pic = ? WHERE emailid = ?"); $stmt->bindParam('1', $pic); $stmt->bindParam('2', $emailid); $stmt->execute(); } } if ($npass1 == $npass2 && $npass1 != null && $npass2 != null) { $stmt = $dbhelper->prepare("UPDATE admin SET name = ?, emailid = ?, pass = ? WHERE emailid = ?"); $stmt->bindParam('1', $fullname); $stmt->bindParam('2', $emailid); $stmt->bindParam('3', $npass1); $stmt->bindParam('4', $emailid); $stmt->execute(); echo "Successfully Updated!";
public function personal_() { eval(USER); try { $data = $_POST; unset($data['__hash__']); $root = C('ROOT'); if (isset($_FILES["picture"])) { $upload = uploadImage(); if (!is_string($upload)) { $data['picture'] = $root . $upload[0]["savepath"] . $upload[0]["savename"]; } if ($data["picture"] == $root) { unset($data["picture"]); } } DBModel::updateDB('cernet_user', array('username' => session('username')), $data); $this->success(Success('modify'), '__ROOT__/User/personal'); } catch (Exception $e) { throw_exception($e->getMessage()); } }
$pasta = '../uploads/'; $ano = date('Y'); $mes = date('m'); if (file_exists($pasta . $postedit['thumb']) && !is_dir($pasta . $postedit['thumb'])) { unlink($pasta . $postedit['thumb']); } if (!file_exists($pasta . $ano)) { mkdir($pasta . $ano, 0755); } if (!file_exists($pasta . $ano . '/' . $mes)) { mkdir($pasta . $ano . '/' . $mes, 0755); } $img = $_FILES['thumb']; $ext = substr($img['name'], -3); $f['thumb'] = $ano . '/' . $mes . '/' . $f['url'] . '.' . $ext; uploadImage($img['tmp_name'], $f['url'] . '.' . $ext, '960', $pasta . $ano . '/' . $mes . '/'); } update('posts', $f, "id = '{$urledit}'"); $_SESSION['return'] = '<span class="alert alert-success" style="float:left;"">Seu Artigo foi atualizado com sucesso, você pode visualiza-lo <a href="' . BASE . '/categoria/' . $f['url'] . '" target="_blanck" title="Ver artigo">aqui</a>, ou precione <span class="label label-info">"F5"</span> para recarregar a página e verificar as alterações caso elas não aparecerem de imediato!</span>'; header('Location: index2.php?exe=posts/posts-edit&editid=' . $urledit); } } elseif (!empty($_SESSION['return'])) { echo $_SESSION['return']; unset($_SESSION['return']); } } ?> <form name="formulario" action="" method="post" class="form-horizontal" enctype="multipart/form-data"> <fieldset> <legend>Editar artigo:<strong style="color:#900"> <?php echo $postedit['titulo'];
function chkartikel($data,$defLang) { global $tax,$erptax,$shop2erp,$KDGrp,$GeoZone,$nopic; if ($data["partnumber"]=="") { echo "Artikelnummer fehlt!<br>"; return;}; if ($data["image"]) { $data["picname"]=(strrpos($data["image"],"/")>0)?substr($data["image"],strrpos($data["image"],"/")+1):$data["image"]; } else if ($nopic) { $data["picname"]=(strrpos($nopic,"/")>0)?substr($nopic,strrpos($nopic,"/")+1):$nopic; $data["image"]=$nopic; } $data["onhand"]=floor($data["onhand"]); echo $data["partnumber"]." ".$data["description"]." -> "; $sql ="select * from products where products_model like '".$data["partnumber"]."'"; $rs=getAll("shop",$sql,"chkartikel"); $data["rate"]=$erptax[$data["bugru"]]["rate"]; if ($rs) { updartikel($data,$rs[0]["products_id"],$defLang); if ($rs[0]["products_image"]<>$data["picname"] and $data["picname"]) uploadImage($data["image"],$rs[0]["products_id"]); } else { $id=insartikel($data,$defLang); if ($data["image"]) uploadImage($data["image"],$id); } echo "<br>\n"; }
function save() { $row = JTable::getInstance('manufacturer', 'Table'); if (!$row->bind(JRequest::get('post'))) { echo $row->getError(); exit; } $row->name = trim($row->name); $row->description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); // upload image $file = JRequest::getVar('image', null, 'files', 'array'); $row->image = JRequest::getVar('old_image'); if (!empty($file['tmp_name'])) { if (!empty($row->image)) { unlink($this->_path . $row->image); } $row->image = uploadImage($file, $this->_path); } if (!$row->store()) { echo $row->getError(); exit; } }
return $eMessage; } } $filename = strip_tags($_REQUEST['filename']); $img = $_FILES["filename"]["name"]; $maxSize = strip_tags($_REQUEST['maxSize']); $maxW = strip_tags($_REQUEST['maxW']); $fullPath = strip_tags($_REQUEST['fullPath']); $relPath = strip_tags($_REQUEST['relPath']); $colorR = strip_tags($_REQUEST['colorR']); $colorG = strip_tags($_REQUEST['colorG']); $colorB = strip_tags($_REQUEST['colorB']); $maxH = strip_tags($_REQUEST['maxH']); $filesize_image = $_FILES[$filename]['size']; if ($filesize_image > 0) { $upload_image = uploadImage($filename, $maxSize, $maxW, $fullPath, $relPath, $colorR, $colorG, $colorB, $maxH); if (is_array($upload_image)) { foreach ($upload_image as $key => $value) { if ($value == "-ERROR-") { unset($upload_image[$key]); } } $document = array_values($upload_image); for ($x = 0; $x < sizeof($document); $x++) { $errorList[] = $document[$x]; } $imgUploaded = false; } else { $imgUploaded = true; } } else {