Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $database = "skp";
- $conn = new mysqli($servername, $username, $password, $database);
- if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error);
- } mysqli_set_charset($conn, "utf8");
- ?>
- <?php
- $_FILES['submit']['name'];
- $_FILES['submit']['type'];
- $_FILES['submit']['size'];
- $_FILES['submit']['tmp_name'];
- mysqli_query($conn,"INSERT INTO upload (name,type,size,content) VALUES ('".$_FILES['name']."'".$_FILES['type']."'".$_FILES['size']."'".$_FILES['tmp_name']."')");
- mysqli_close($conn);
- $uploaddir = "upload/";
- $uploadfile = $uploaddir . basename($_FILES["submit"]["name"]);
- $uploadOk = 1;
- if (move_uploaded_file($_FILES['submit']['tmp_name'], $uploadfile)) {
- echo "File is valid, and was successfully uploaded.\n";
- } else {
- echo "Possible file upload attack!\n";
- }
- echo 'Here is some more debugging info:';
- print_r($_FILES);
- print "</pre>";
- if (file_exists($uploadfile)) {
- echo "Sorry, file already exists.";
- $uploadOk = 0;
- }
- if ($_FILES["upload"]["size"] > 500000) {
- echo "Sorry, your file is too large.";
- $uploadOk = 0;
- }
- $f_type = $_FILES['upload']['type'];
- if ($f_type== "image/gif" OR $f_type== "image/png" OR $f_type== "image/jpeg" OR $f_type== "image/JPEG" OR $f_type== "image/PNG" OR $f_type== "image/GIF"){
- $error=False;
- }else{
- $error=True;}
- if ($uploadOk == 0) {
- echo "Sorry, your file was not uploaded.";
- } else {
- if (move_uploaded_file($_FILES["submit"]["tmp_name"], $target_file)) {
- echo "The file ". basename( $_FILES["submit"]["name"]). " has been uploaded.";
- } else {
- echo "Sorry, there was an error uploading your file.";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement