Forum Moderators: coopster
copy($HTTP_POST_FILES['userfile']['tmp_name'], "./var/www/html/upload/." .$HTTP_POST_FILES['userfile']['name'])
or die ("Copying file failed! ");
Then I put the original filename of the image in a MySQL database. But I get only the tmpname, like: /tmp/phpcRkEDa or /tmp/phpgeZl3A instead of picture1.jpg
Can anyone tell me how to fix this problem?
Thanx!
Anand
I think the problem lies somewhere in this code:
(You can choose an image from a form (browse) and then submit the form.)
if ($HTTP_POST_VARS['submituser'] == "SUBMIT DATA") {
$sql = "INSERT INTO Users (foto) VALUES ('$userfile')";
if (@mysql_query($sql)) {
echo("<p>Your userdata has been added.</p>");
} else {
echo("<p>Error adding submitted userdata: " .mysql_error() . "</p>");
}
}
I think the value of $userfile is the tempname. I don't know why.
if ($HTTP_POST_VARS['submituser'] == "SUBMIT DATA")
$name = $_FILES[userfile][name];
{
$sql = "INSERT INTO Users (foto) VALUES ('$name')";
if (@mysql_query($sql)
{
echo("<p>Your userdata has been added.</p>");
}
else
{
echo("<p>Error adding submitted userdata: " .mysql_error() . "</p>");
}
}
:)