-3

<?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');

                                }
                                    }
                        }

?>

2
Contributors
3
Replies
18
Views
1 Year
Discussion Span
Last Post by rproffitt
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.