// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES.
if(!empty($_FILES["userfile"]))
{
$uploaddir = "/home/tom/vtiger1.0/installs/apache/htdocs/vtigerCRM/test/upload/" ;// set this to wherever
//copy the file to some permanent location
if (move_uploaded_file($_FILES["userfile"]["tmp_name"],$uploaddir.$_FILES["userfile"]["name"]))
{
//make blob and store in DB
include "open_db.php";
if (isset($_FILES["userfile"]))
{
echo "inside";
$data = addslashes(fread(fopen($userfile, "r"), filesize($userfile)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO filestorage ";
$sql .= "(description, data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$userfile_name', '$userfile_size', '$userfile_type')";
echo "sql" .$sql;
$result = mysql_query($sql, $db);
mysql_free_result($result); // it's always nice to clean up!
echo "Thank you. The new file was successfully added to our database.
";
// echo "Continue";
}
mysql_close();
}
else
{
echo ("error in uploading file. Please check the size of the file !");
}
}
?>