jeudi 2 mars 2017

multiple image path storing database and html

<html>
<body>
<form class="container" enctype ='multipart/form-data' action="add.php" method="post">
<label><b>Name:</b></label><br><br>
<input type="text" name="name"><br><br>
<label><b>Type:</b></label><br><br>
<input type="text" name="type"><br><br>
<label><b>Detail:</b></label><br><br>
<input type="text" name="detail"><br><br>
<label><b>Area:</b></label><br><br>
<input type="text" name="area"><br><br>


    Select image to upload:
    <input type="file" name="filename" size='10000' multiple>
    <input type="submit" value="Upload Image">
</form>


<?php


//error_reporting(E_ALL); ini_set('display_errors', 1);

require_once 'login.php';
$db_server= mysqli_connect($db_hostname, $db_username, $db_password,$db_database);
if (!$db_server) die("unable to connect to mysqli:".mysqli_error());



mysqli_select_db($db_server,"dbase1")
or die("db not selected".mysqli_error());


$name= $_POST["name"];
$type= $_POST["type"];
$detail= $_POST["detail"];
$area= $_POST["area"];


if($_FILES)
{
    $namee=$_FILES['filename']['name'];
    move_uploaded_file($_FILES['filename']['tmp_name'],$namee);
    echo"uploaded image'$namee'<br><img src ='$namee'>";
}

$source= "pictures/".$namee;

$sql=" INSERT INTO adprop (name, type, text,area,filename) VALUES ('$name','$type','$detail','$area','$source')";
$db=$db_server->query($sql);






?>



</body>
<html>

hello i am new in php actually i am trying to add multiple images with text to database and stuck if i select one it gets stored if i select multiple it left as blank in database i need help to resolve plus i am confuse if one table for image in db is ok? i mean is there special datatype or way to have multiple images against same entery in database thanks advance for help!




Aucun commentaire:

Enregistrer un commentaire