|
- <!DOCTYPE html>
- <!--
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
- -->
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Upload</title>
- </head>
- <body>
-
-
-
- <?php
-
-
- if (isset($_FILES["file"]["name"])) {
-
- $name = $_FILES["file"]["name"];
- $temp_file = $_FILES['file']['tmp_name'];
- $error = $_FILES['file']['error'];
-
-
-
-
-
- $imginfo_array = getimagesize($temp_file); // returns a false if not a valid image file
-
- if ($imginfo_array !== false) {
- $mime_type = $imginfo_array['mime'];
- switch($mime_type) {
- case "image/jpeg" ||"image/gif" || "image/png":
- $location = 'pictures/';
- move_uploaded_file($temp_file, $location.$name);
- echo 'Uploaded successfully.';
- }
- }
- else {
- echo "This is not a valid image file";
- }
-
- }
-
-
- ?>
-
- <form action="upload_picture.php" method="POST" enctype="multipart/form-data">
- <input type="file" name="file"><br><br>
- <input type="submit" value="Submit">
- </form>
- </body>
- </html>
|