Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1.     $old_id = $_GET['id'];
  2.    
  3.     if(!empty($_FILES['soubor1']['name'])) { $file1 = $_FILES['soubor1']; $mini = $_FILES['soubor1']['name']; }
  4.     if(!empty($_FILES['soubor2']['name'])) { $file2 = $_FILES['soubor2']; $full = $_FILES['soubor2']['name']; }
  5.     if(!empty($_POST['popisek'])) { $note = $_POST['popisek']; }
  6.    
  7.     if($file1 || $file2 || $note) { // pokud aspon jedna existuje
  8.        
  9.         //prvni fotka
  10.         if(isset($file1)) {
  11.             if(in_array( $_FILES['soubor1']['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/pjpeg'))) {
  12.                 if( @move_uploaded_file($_FILES['soubor1']['tmp_name'], "images/gallery/" . $folder . "/mini/" . $_FILES['soubor1']['name'])) {
  13.                     unlink("images/gallery/" . $folder . "/mini/" . );
  14.                 } else {
  15.                     $error[0] = "minitura nelze nahrát, zkuste to znovu";
  16.                 }
  17.             } else {
  18.                 $error[0] = "špatný formátu miniatury, očekává se png, jpg*";
  19.             }
  20.         }
  21.  
  22.         //druha fotka
  23.         if(isset($file2)) {
  24.             if(in_array( $_FILES['soubor2']['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/pjpeg'))) {
  25.                 if( @move_uploaded_file($_FILES['soubor2']['tmp_name'], "images/gallery/" . $folder . "/" . $_FILES['soubor2']['name'])) {
  26.                     unlink("images/gallery/" . $folder . "/" . );
  27.                 } else {
  28.                     $error[0] = "velká fotografie nelze nahrát, zkuste to znovu";
  29.                 }  
  30.             } else {
  31.                 $error[1] = "špatný formátu celé fotky, očekává se png, jpg*";
  32.             }
  33.         }
  34.        
  35.         if(empty($error)) {
  36.             $sql = "UPDATE foto SET ";
  37.             if(isset($file1)) { $sql .= "mini = '$mini'"; }
  38.             if(isset($file2) && !isset($file1)) { $sql .= "full = '$full'"; } else if(isset($file2)) { $sql .= ", full = '$full'"; }
  39.             if(isset($note) && !isset($file1) && !isset($file2)) { $sql .= "nazev = '$note'"; } else if(isset($note)) { $sql .= ", nazev = '$note'"; }
  40.             $sql .= " WHERE id = '$old_id'";
  41.             // $query = mysql_query($sql, $con);
  42.             if($query) {
  43.  
  44.             }
  45.         } else {
  46.             echo $error[0];
  47.             echo $error[1];
  48.         }
  49.    
  50.     } else {
  51.         echo "žádná editace není vybrána";
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement