-2

我正在学习 php 和 phpmyadmin 我想将图像上传到数据库然后将相同的图像回显到另一个页面任何人都可以帮助我

索引.html

<html>
<body>
    <form name="form" method="post" action="insert_ac.php">
      <h1>Insert Data Into mySQL Database</h1>

            name......    <input name="name" type="text" id="name"> <br><br>
            username....  <input name="username" type="text" id="username"> <br><br>
            password..    <input name="password" type="text" id="lastname"><br><br>
            Email.....    <input name="email" type="text" id="email"><br><br>
            Upload Image....... :<input type="file" name="image" id="uploadimg"><br>
      <input type="submit" name="Submit" value="Submit">
    </form>
</body>
</html>

插入ac.php

<?php

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="loginfour"; // Database name
$tbl_name="test_four"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Get values from form
$username=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];
$name=$_POST['name'];

// Insert data into mysql
$sql="INSERT INTO $tbl_name(username, password, email, name)VALUES('$username', '$password', '$email', '$name')";
$result=mysql_query($sql);

// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='insert.php'>Back to main page</a>";
}

else {
echo "ERROR";
}
?>

<?php
// close connection
mysql_close();
?>

我想上传图像并将其显示给 insert_ac.php 任何人都可以帮助我............

4

1 回答 1

0

php页面很简单

echo($_FILES["image"]["name"]);

参考

于 2013-09-27T13:16:59.963 回答