<?php

require('config.php');

                        if (!isset($_FILES['image']['tmp_name'])) {
                        echo "";
                        }else{
                        $file=$_FILES['image']['tmp_name'];
                        $image = $_FILES["image"] ["name"];
                        $image_name= addslashes($_FILES['image']['name']);
                        $size = $_FILES["image"] ["size"];
                        $error = $_FILES["image"] ["error"];

                        if ($error > 0){
                                    die("Error uploading file! Code $error.");
                                }else{
                                    if($size > 10000000) //conditions for the file
                                    {
                                    die("Format is not allowed or file size is too big!");
                                    }

                                else
                                    {

                                move_uploaded_file($_FILES["image"]["tmp_name"],"upload/" . $_FILES["image"]["name"]);          
                                $location=$_FILES["image"]["name"];
                                $fname= $_POST['fullname'];


                    $register="INSERT INTO image (image_id,location) 
                                values('$fname','$location')"
                                or die("error".mysqli_errno($db_link));
                    $result=mysqli_query($db_link,$register);

                        header('location:registation.php');

                                }
                                    }
                        }

?>

Recommended Answers

I gave this a -1. You dumped code without crafting a nice post title as well as left this to imagination what help is required.

Try harder next time.

PS. Why does this look like code from 2013 posts like

Jump to Post

All 3 Replies

thank you.
am trying to upload and store image into my database. its doesn't show any error and its doesn't go into the database also.
i need help to solve this.

And why does it look like posts from years ago? You should understand your code even if you lifted it off the web. Then you work it line by line and then, when asking for help, make a good post with a title that makes sense along with what line of code is failing.

No one knows your SQL server setup either. You never told if the file made it into your system. I read it but you could echo/print (use what PHP uses) about line 9 all those items to see if they look good at that point.

Are you debugging your code? It doesn't look like it yet. That is, I'm seeing a lot of new programmers that forget basic debugging.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.