Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isset($_REQUEST['submit_request'])){
- $insert_query= "INSERT INTO images SET text='$text',image='$image'";
- $query= mysqli_query($connection,$insert_query);
- echo '
- Success! uploaded image into the database!
- ';
- <?php
- $dbhost = 'localhost';
- $dbUsername = 'root';
- $dbpassword = '';
- $dbname = 'photos';
- //Creating connection and selecting database
- $db = new mysqli($dbhost,$dbUsername,$dbPassword,$dbName);
- //Checking connection
- if($db->connect_error){
- die("Connection failed:". $db->connect_error);
- }
- //Getting image from the database
- $result = $db->query("SELECT image FROM images WHERE id = {$_GET['id]}");
- if($result->num_rows > 0){
- $imgData = $result->fetch_assoc();
- //Rendering Image
- header("Content-type: image/jpg");
- echo $imgData["image"];
- }else{
- echo "Image not Found...";
- }
- }
Add Comment
Please, Sign In to add comment