Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="upload.php" method="POST">
- <input type="file" name="image">
- <input type="submit" name="submit" value="upload">
- </form>
- <?php
- if(isset($_POST['submit']))
- {
- $conn= mysqli_connect("localhost","root","");
- mysqli_select_db($conn, "namastedb");
- $imageName = mysqli_real_escape_string($conn, $_FILES["image"] ["name"]);
- $imageData = mysqli_real_escape_string($conn, file_get_contents($_FILES["image"] ["tmp_name"]));
- $imageType = mysqli_real_escape_string($conn, $_FILES["image"]["type"]);
- if(substr($imageType, 0, 5) == "image")
- {
- mysql_query("insert into 'product_details' values('','1','$imageName','$imageData') ");
- echo "Image Uploaded.";
- }
- else
- echo "Only images are allowed!";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement