0

好的,我知道我刚刚问了一个关于这个的问题,但是现在我让它将图像上传到数据库并尝试重新做一些事情来让文本进入那里我将所有内容都添加回了名字,但它似乎没有能够返回任何帮助都会很棒,谢谢顺便说一句,这个社区很棒。

    <html>
    <head>
    <title>Upload an image</title>
</head>
<body>
<form action="UploadContent.php" method="POST" enctype="multipart/form-data">
<p>FirstName:</p><input type="FirstName" name"FirstName"/>

<p>File:</p><input type="file" name="image"> 

<input type="submit" value="Upload">
</form>
<?php

// connect to database
include"config.php";

// file properties
$FirstName = $_POST['FirstName'];

$file = $_FILES['image']['tmp_name'];

if (!isset($file))
echo "Please select a profile pic";
else
{
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);

if ($image_size==FALSE)
echo "That isn't a image.";
else
{
$insert = mysql_query("INSERT INTO content VALUES     ('".$FirstName."','','','','','','','','','$image_name','$image')");
}
}
?>
</body>
</html>

我改变了我的插入代码如下

$insert = mysql_query("INSERT INTO content (FirstName, LastName, Gender, City, State, BirthMonth, BirthDay, BirthYear, ProfileUrl, ProfilePicName, ProfilePic) VALUES ('".$FirstName."','".$LastName."','".$Gender."','".$City."','".$State."','".$BirthMonth."','".$BirthDay."','".$BirthYear."','".$ProfielUrl."','$image_name','$image')");

因为我试图让这个 youtube 视频提供帮助,但仍然没有运气

http://www.youtube.com/watch?v=xAkunfiZwYQ

4

1 回答 1

0

Well, whether you get your answer or not but i am not agree with your approach of storing images into database, you may (not may have to) store them in a file system, and the path in database, that will be the correct way to do. here is an good stack post to read Storing images

于 2012-11-20T05:18:16.197 回答