Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername ="localhost";
- $user ="root";
- $pass= "";
- $db ="img_upload";
- $conn = new mysqli($servername,$user,$pass,$db);
- if(isset($_POST['upload'])){
- $description= $_POST["description"];
- $file_tmp = $_FILES["img_file"]["tmp_name"];
- $file_name = $_FILES["img_file"]["name"];
- $file_type = $_FILES["img_file"]["type"];
- $file_path = "images/".$file_name;
- move_uploaded_file($file_tmp, $file_path);
- $sql = "INSERT INTO img_list(img_tmp,img_name,img_type,description) VALUES ('$file_tmp','$file_name','$file_type','$description')";
- $result = $conn->query($sql);
- if ($result) {
- echo "<script>";
- echo "alert('Image successfully uploaded');";
- echo "</script>";
- }
- else{
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement