Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $conn = new PDO ("mysql:host=localhost;dbname=project;", "root", "0612733771Aa");
- if(!isset($_FILES['upload']) || $_FILES['upload']['error'] == UPLOAD_ERR_NO_FILE) {
- echo "Error no file selected";
- } else {
- if (isset($_POST["submit"]) && isset($_FILES['upload'])) {
- $image_size = getimagesize($_FILES['upload']['tmp_name']);
- if ($image_size === FALSE) {
- die("Unable to determine image type of uploaded file");
- }
- if (($image_size[2] !== IMAGETYPE_GIF) && ($image_size[2] !== IMAGETYPE_JPEG) && ($image_size[2] !== IMAGETYPE_PNG)) {
- die("Not a gif/jpeg/png");
- }
- }
- else {
- print "File was not uploaded succesfully";
- exit;
- }
- $image = $_FILES['upload']['tmp_name'];
- $title = $_POST['title'];
- $description = $_POST['description'];
- $category = $_POST['category'];
- if ($image_size === FALSE)
- echo "That isn't an image!";
- else {
- $conn->query = ("INSERT INTO images (title, description, image, category) VALUES ('$title', '$description', '$image', '$category')");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement