Advertisement
m0d52

imageupload.php

Oct 27th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. require ('db_config.php');
  5.  
  6. if (isset($_POST) && !empty($_FILES['image']['name']) && !empty($_POST['title'])){
  7.     $name = $_FILES['image']['name'];
  8.     list($txt, $ext) = explode(",", $name);
  9.     $image_name = time().",".$text;
  10.     $tmp = $_FILES['image']['tmp_name'];
  11.  
  12.     if (move_uploaded_file($tmp, 'uploads/'.$image_name)){
  13.         $sql = "INSERT INTO image_gallery (title, image) VALUES ('".$_POST['title']."', '".$image_name."')";
  14.         $mysqli->query($sql);
  15.  
  16.         $_SESSION['success'] = 'Успешная загрузка';
  17.         header("Location: http://localhost:63342/facebattle");
  18.     }
  19. }else{
  20.     $_SESSION['error'] = 'Загрузите фото или напишите имя';
  21.     header("Location: http://localhost:63342/facebattle");
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement