I am able to upload a file and echo these. But now I would like to upload these to my database. How would I go onto doing this. I found something like this for C++. but not sure how to convert this to PHP.
this is what I found
// previously setup variables
IBPP::Database db;
IBPP::Transaction tr;
IBPP::Statement st;
std::string file_content; // loaded from file: myfile.pdf
// writing file data to Blob column
st->Prepare("INSERT INTO t1 (file_name, file_data) VALUES (?, ?)");
st->Set(1, "myfile.pdf");
IBPP::Blob b = IBPP::BlobFactory(db, tr);
b->Save(file_content);
st->Set(2, b);
st->Execute();
This is what I have so far
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
// echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
//echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
$filename = "upload/" . $_FILES["file"]["name"];
$fd = fopen ($filename, "r");
$contents = fread ($fd,filesize ($filename));
fclose ($fd);
$delimiter = ".";
$splitcontents = explode($delimiter, $contents);
foreach ( $splitcontents as $color )
{
echo "<b>Question </b> $color<br>";
}
?>