大家好我每次写一个代码来保存数据库中的标题和图像名称,但在我的PHP代码中,我可以将标题文本和图像名称保存在数据库中,但图像不能保存在文件夹中(uploadedimages),
这是我的代码:
<?php
include 'config.php';
$title = $_POST['title'];
$base=$_REQUEST['image'];
$filename = $_REQUEST['filename'];
$binary=base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
$file = fopen('uploadedimages/'.$filename, 'wb');
fwrite($file, $binary);
fclose($file);
mysql_query("insert into test_upload(title,img) values('$title','$filename' )");
echo "[".$title."]send";
?>
答案 0 :(得分:0)
添加以下代码
$filename = $_FILES['filename']['name'];
if (move_uploaded_file($_FILES['filename']['tmp_name'], 'uploadedimages/.'$filename))
{
echo "upload succeed";
} else {
echo "Upload failed";
}