Php 是否在输入图像字段上方显示边框?

Php 是否在输入图像字段上方显示边框?,php,ajax,image,mysqli,border,Php,Ajax,Image,Mysqli,Border,是否有办法在图像输入字段上方显示边框,以便显示上传的图像 我的HTML代码是: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>form practice</title> <script s

是否有办法在图像输入字段上方显示边框,以便显示上传的图像

我的HTML代码是:

<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>form practice</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script>
        $(document).ready(function(){

            $("#dob").change(function(){
                var value = $("#dob").val();
                var dob = new Date(value);
                var today = new Date();
                var age = Math.floor((today-dob) / (365.25 * 24 * 60 * 60 * 1000));
                if(isNaN(age)) {

                    // will set 0 when value will be NaN
                    age=0;
                }
                else {
                    age=age;
                }
                $('#age').val(age);

            });

        });
    </script>

    <style>

        #profilepic {
            border-style: solid;
            border-width: 2px;
            margin-top: 150px;
        }

    </style>
  </head>

  <body>

    <div class="form2" id="form2" name="form2">

      <form action="php/form2.php" method="post" id="Personalinfo">

        <label for="fname">Name:</label>
        <input type="text" id="fname" name="firstname" placeholder="Client Name..">

        <label for="lname">Lastname:</label>
        <input type="text" id="lname" name="lastname" placeholder="Client Lastname..">

        <label for="dob">Birthday:</label>
        <input type="text" id="dob" name="dob" placeholder="yyyy/mm/dd..">

        <label for="age">Age:</label>
        <input type="text" id="age" name="age" placeholder="Client Age.."><br><br>

        <label for="profilepic">Profile Picture:</label>
        <input type="file" id="profilepic" name="profilepic" accept="image/*" placeholder="Όνομα Πελάτη.." border="5"><br><br>

        <input type="submit" name="submitForm2" value="Submit">


      </form>
    </div>

  </body>
</html>

形式练习
$(文档).ready(函数(){
$(“#dob”).change(函数(){
var值=$(“#dob”).val();
var dob=新日期(值);
var today=新日期();
变量年龄=数学楼层((今天的dob)/(365.25*24*60*60*1000));
if(isNaN(年龄)){
//值为NaN时将设置为0
年龄=0;
}
否则{
年龄=年龄;
}
$('年龄').val(年龄);
});
});
#剖面图{
边框样式:实心;
边框宽度:2倍;
边缘顶部:150px;
}
姓名:
姓氏:
生日:
年龄:


个人资料图片:

我在MySQLi数据库中存储数据的PHP代码是:

<?php
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "testdb";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 

    if (isset($_POST['submitForm2'])) {
        $firstname = $_POST['firstname'];
        $lastname = $_POST['lastname'];
        $dob = $_POST['dob'];
        $age = $_POST['age'];
        $profilepic = $_POST['profilepic'];

        $sql = "INSERT INTO info (firstname, lastname, dob, age, profilepic)
                VALUES ('{$firstname}', '{$lastname}', '{$dob}', '{$age}', '{$profilepic}')";

        if ($conn->query($sql) === TRUE) {
            echo "New record created successfully";
        } else {
            echo "Error: " . $sql . "<br>" . $conn->error;
        }

    } else {
        echo "Are you sure you enter a firstname and the name of your html submit 
              is submitForm";
    }

    $conn->close();

?>

只是一个想法,用你的代码试试这个

$('input[type=file]')。更改(函数(){
$('dummyImg').attr('src',URL.createObjectURL(event.target.files[0]);
});
#dummyimmg{宽度:100%;}
.img块{边框:2px纯青色;宽度:400px;}

个人资料图片:



只是一个想法,用你的代码试试这个

$('input[type=file]')。更改(函数(){
$('dummyImg').attr('src',URL.createObjectURL(event.target.files[0]);
});
#dummyimmg{宽度:100%;}
.img块{边框:2px纯青色;宽度:400px;}

个人资料图片:



那你想要什么?边框还是图片?谢谢回复!一个有虚拟图片的边框会很棒,但是仅仅一个边框也会很有帮助!那你想要什么?边框还是图片?谢谢回复!一个有虚拟图片的边框会很棒,但是仅仅一个边框也会很有帮助!朋友,它工作得很好,但当我上传img时,它不会显示在边框上!知道为什么会这样吗?朋友,它工作得很好,但是当我上传img时,它不会显示在边框上!知道为什么会这样吗?