Skip to main content

IMAGE UPLOAD

<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            div.centre {
                width: 500px;
               
                background-color: white;
                margin-left: auto;
                margin-right: auto;
                padding: 10px;
                height: 400px;
                margin-top: 60px;
            }
            h1{
                text-align: center;
            }
            input[type=submit], input[type=reset]{
                padding: auto;
            }
        </style>
    </head>
    <body>
        <form action="pro_val.php" method="post" enctype="multipart/form-data">
        <center>
            <div class="centre">
                   
                <h1>Profile Information</h1>
                <hr>
                        <table>
                            <tr>
                                <td>
                                        Select Image:
                                </td>
                                <td>
                                    <input type="file" name="image" id="fileToUpload">
                                </td>
                            </tr>
                           
                            <tr>
                                <td><label for="fname">Name:</label></td>
                                <td><input type="text" name="txtfname" placeholder="First Name"></td>
                               
                                <td><input type="text" name="txtmname" placeholder="Middel Name"></td>
                               
                                <td><input type="text" name="txtlname" placeholder="Last Name"></td>
                            </tr>
                            <tr>
                                <td><label for="Genderfm">Gender:</label></td>
                                <td><input type="radio" name="Gender" value="Male">Male</td>
                                <td><input type="radio" name="Gender" value="Female" checked="true">Female</td>
                            </tr>
                            <tr>
                                 <td>City:</td>
                                <td>
                                    <select name="city">
                                        <option value="Bharuch">Surat</option>
                                        <option value="Ankleshwar">Ankleshwar</option>
                                        <option value="Surat">Bharuch</option>
                                        <option value="Bardoli">Bardoli</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>Hobby:</td>
                               
                                <td><input type="checkbox" name="hobby[]" value="Eating" checked="true">Eating</td>
                                <td><input type="checkbox" name="hobby[]" value="Traveling" checked="true">Traveling</td>
                                <td><input type="checkbox" name="hobby[]" value="Sleeping">Sleeping</td>
                                <td><input type="checkbox" name="hobby[]" value="Riding">Riding
                                </td>
                            </tr>
                            <tr>
                                <td><label for="work">Date Of Birth:</label></td>
                                <td>
                                    <select name="Month">
                                        <option value="selectoption" selected>Month</option>
                                        <option value="1">January</option>
                                        <option value="2">February</option>
                                        <option value="3">March</option>
                                        <option value="4">April</option>
                                        <option value="5">May</option>
                                        <option value="6">June</option>
                                        <option value="7">July</option>
                                        <option value="8">August</option>
                                        <option value="9">September</option>
                                        <option value="10">October</option>
                                        <option value="11">November</option>
                                        <option value="12">December</option>
                                    </select>
                                </td>
                               
                                <td>
                                    <select name="Day">
                                        <?php
                                            for($i=1;$i<=31;$i++)
                                            {
                                                echo "<option>$i</option>";
                                            }
                                        ?>
                                    </select>
                                </td>
                                <td>
                                    <select name="year">
                                        <?php
                                            for($i=1995;$i<=2018;$i++)
                                            {
                                                echo "<option>$i</option>";
                                            }
                                        ?>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input type="submit" value="UploadImage" name="submit">
                                </td>
                            </tr>
                        </table>
                   
                </div>
        </center>
        </form>
        <?php
        // put your code here
        ?>
    </body>
</html>
========================================================================
PRO.PHP
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
         <style>
            div.centre {
                width: 500px;
                
                background-color: white;
                margin-left: auto;
                margin-right: auto;
                padding: 10px;
                height: 650px;
                margin-top: 60px;
            }
            h1{
                text-align: center;
            }
        </style>
    </head>
    <body>
        <?php
            if (isset($_FILES['image']))
            {
                $errors = array();
                $file_name=$_FILES['image']['name'];
                $file_size=$_FILES['image']['size'];
                $file_tmp=$_FILES['image']['tmp_name'];
                $file_type=$_FILES['image']['type'];
                #$file_exe=  strtolower(end(explode('.',$_FILES['image']['name'])));
                $imageFileType=  strtolower(pathinfo($file_name,PATHINFO_EXTENSION));
                $target_file="uploads/".basename($_FILES['image']['name']);
                
            }
        ?>
        <div class="centre">
        <form>
            <center>
        <B>
            <h1>Profile Information</h1>
        </B>
        <table border="1">
                <tr>
                    <th>
                        Information:
                    </th>
                    <th>
                        Description:
                    </th>
                </tr>
                <tr>
                    <td>
                        Name:
                    </td>
                    <td>
                        <?php
                            echo $_POST["txtfname"]." ".$_POST["txtmname"]." ".$_POST["txtlname"];
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        Gender:
                    </td>
                    <td>
                        <?php
                            echo $_POST["Gender"];
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        City:
                    </td>
                    <td>
                        <?php
                            echo $_POST["city"];
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        Gender:
                    </td>
                    <td>
                        <?php
                            echo $_POST["Gender"];
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        Hobby:
                    </td>
                    <td>
                        <?php
                            foreach ($_POST['hobby'] as $value)
                            {
                                echo "$value";
                                echo "<br>";
                            }
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        Date Of Birth:
                    </td>
                    <td>
                        <?php
                        echo $_POST['Month']."/".$_POST["Day"]."/".$_POST["year"];
                            /*foreach ($_POST['hobby'] as $value)
                            {
                                echo "$value";
                                echo "<br>";
                            }*/
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        File Size:
                    </td>
                    <td>
                        <?php
                            echo $file_size;
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        File Temporary Name
                    </td>
                    <td>
                        <?php
                            echo $file_tmp;
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        File Type:
                    </td>
                    <td>
                        <?php
                            echo $file_type;
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        File Extension:
                    </td>
                    <td>
                        <?php
                            echo $imageFileType;
                            
                            $expensions = array("jpeg","jpg","png");
                            if(file_exists($target_file))
                            {
                                echo "sorry,file already exists";
                            }
                            if(in_array($imageFileType, $expensions)=== FALSE)
                            {
                               // $errors[]="Extension not allowed ,only allowed JPEG or PNG file.";
                            }
                            if($file_size>2097152)
                            {
                                $errors[]="File size must be excately 2 MB";
                            }
                            if(empty($errors)==true)
                            {
                                move_uploaded_file($file_tmp,"uploads/".$file_name);
                            }
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        File Uploaded Status:
                    </td>
                    <td>
                        <?php
                            echo "Success";
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        Uploaded File:
                    </td>
                    <td>
                        <?php
                            echo "<img src=".$target_file." height=200px width=200px />";
                        ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        File Uploaded Status:
                    </td>
                    <td>
                        <?php
                        print_r($errors);
                        ?>
                    </td>
                </tr>
                
            </center>
        </table>
        </form>
        </div>
    </body>
</html>

Comments

Popular posts from this blog

DELL ES

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html>     <head>         <meta charset="UTF-8">         <title></title>     </head>     <body>         <?php                     include './Conn.php';                     $sv="select * from demo";                     $qsv= mysqli_query($conn, $sv);                                 ?>     <center>         <table border="1">           ...

SRCH OP

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php ob_start(); ?> <html>     <head>         <meta charset="UTF-8">         <title></title>         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>     </head>     <style>       body{           background-color: aliceblue;       }   </style>     <body>     ...

IMAGE UP BACK

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html>     <head>         <meta charset="UTF-8">         <title></title>         <style>             h1{                 font-family: monospace;                 color: black;                 text-align: center;             }             h3{                 text-align: left;             }         </style>     </head>     <body> ...