我正在编写代码,可以在其中上传图像到文件夹中并将数据表单保存到Mysql数据库中.目前,仅将数据表单保存在db表中是可行的,但我无法将图像上传到文件夹中.这是代码:
if(isset($_POST['upload_img'])){
$file_name = $_FILES['image']['name'];
$file_type = $_FILES['image']['type'];
$file_size = $_FILES['image']['size'];
$file_tmp_name = $_FILES['image']['tmp_name'];
if($file_name){
move_uploaded_file($file_tmp_name,"images/$file_name");
}
}
?>
include 'guestconfig/config.php';
if (isset($_POST['upload_img']) && $_POST['upload_img']=="invia")
{
$image = $file_name;
$title = addslashes($_POST['title']);
$price = addslashes($_POST['price']);
$sql = "INSERT INTO testone
(image,title,price) VALUES ('$image', '$title','$price')";
if($result = mysql_query($sql) or die (mysql_error()))
{
echo "Inserimento avvenuto con successo.
Vai alla Home Amministrazione";
}
}else{
?>
|
upload image title: price: |
}
?>
我希望你能帮助我.谢谢!
标签:mysql,php,image-uploading
来源: https://codeday.me/bug/20191118/2028270.html