0

Okay I know I just asked a question about this but now I have it uploading the image to the data base and tried to re do some things to get the text to go in there I added everything back in for the first name but it dosnt seem to be making its way back any help would be amazing thank you btw this community is awesome.

    <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>

I changed my insert code as follows

$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')");

because I was trying to get this youtube video to help but still no luck

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

Bishop Morley
  • 193
  • 1
  • 2
  • 8
  • I'm pretty sure you can't store physical images in the database. A better solution would be to store the image on your server, and store a link to the image in the database. You could even set the image name to a randomly generated ID and store that ID in the database. – Felix Guo Nov 20 '12 at 05:07
  • You can take a look at this for more information on the topic of storing images. http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay – Felix Guo Nov 20 '12 at 05:09
  • Might or might not work with the right database escaping function, given the image data column was actually a BLOB. Also, are you still coding without `error_reporting()` or checking `mysql_error()`? – mario Nov 20 '12 at 05:10

1 Answers1

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

Community
  • 1
  • 1
Ravi
  • 2,078
  • 13
  • 23