You can see the upload page here: http://www.clpoetics.com/test/index.php.
Just for notice this is the code I am currently using to insert the data into mysql and it works perfectly for files under 1MB.
Code: Select all
<?
if ($action == "upload") {
// ok, let's get the uploaded data and insert it into the db now
include "open_db.inc";
if (isset($binFile) && $binFile != "none") {
$data = addslashes(fread(fopen($binFile, "rb"), filesize($binFile)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO tbl_Files ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
$result = mysql_query($sql, $db);
if(!$result == 0) {
echo "Thank you. The new file $binFile_name<br>Size: $binFile_size<br>Type:$binFile_type<br>Was successfully added to our database with the following description:<br>$txtDescription<br><br>";
echo "<a href="/test/index.php">Add another file.</a>";
} else {
echo "The file $binFile_name<br>Size: $binFile_size<br>Type: $binFile_type<br>was not added properly for an unknown reason.<br>";
echo "<a href="/test/index.php">Please try another file.</a>";
}
}
mysql_close();
} else {
//all that follows is the HTML which shows the upload form
}
?>Can the variable $binFile be split into multiple variables of 1MB a each.
If so then I could transfer them each into a temp table in my database and then append them together.
Forgive me if this post seems somewhat confusing as I am not sure how to exactly explain this. Either way it should be somewhat like the following:
//a variable holding 3.5MB of data exists and is to be transferred to a
//mysql database
$largeuserfile
//this file needs to be split into 1MB sections
//----HOW DO I DO THAT!!???----
function to_split_variable($largeuserfile) {
????
????
????
return $splitfile1, $splitfile2, $splitfile3, $splitfile4;
//would probably be best if it could be split into an array
}
I would then transfer each array seperately into the database.
Once inside the database I would append, to the $splitfile1, the data in the database starting from $splitfile2 and so on.
Any ideas on how I could do this?