Web Hosting Talk







View Full Version : uploading and mysql, please look!


brcolow
10-26-2002, 01:16 AM
hey, I have this php script which runs off of a html form so my staff can post screenshots about games.
Please note that because this is vb come things come out a little weird like with the links and stuff but hopefully you'll get it, thanks.

<?
$id = $HTTP_POST_VARS['id'];
$screenshot = $HTTP_POST_FILES['userfile']['name'];
$comment = $HTTP_POST_VARS['comment'];

if (is_uploaded_file($HTTP_POST_FILES['userfile'])) {
copy($HTTP_POST_FILES['userfile'], "D:\www\www.flashstand.com\images\screenshots\tmp");
} else {
echo "Possible file upload attack: filename '$HTTP_POST_FILES[userfile]'.";
}
move_uploaded_file($_FILES['userfile']['tmp_name'], "D:\www\www.flashstand.com\images\screenshots");




$db = mysql_pconnect("localhost", " ", " ");
if (!$db)
{

echo "<b>Could not connect to database, try again later.</b>";

exit;

}
mysql_select_db("news");
$query = "insert into revscreenshots (id,screenshot,comment) values ('$id', '$screenshot', '$comment')";
print" $screenshot uploaded and saved to database!";
?>

Now, would this eniterly work... would it upload the image, put the image path in mysql, put the comment in a database and the id (that comes off the form)?
Thanks,
Mike

brcolow
10-26-2002, 03:09 PM
bump

sylow
10-27-2002, 05:00 AM
create an upload class and use it everytime. Or download from somewhere.
your code looks like a mess.
MHO