I have found a couple of code snippets on uploading files to mySQL. The uploads work fine, but the code shows that it will pull the filename, filetype, and filesize. I have created workarounds for filename using basename and filesize using filesize, but I can't get it to report filetype (ie.. image/jpeg). How do I get this info from a file. Here is the code before I modified to get filename and filesize
Code:
<?php
$db = mysql_connect("localhost", "root","");
mysql_select_db("mybuddy",$db); //connects to our mybuddy database
//replace the above two string's with your database specific values
if (isset($binary_File) && $binary_File != "none")
{
$data = addslashes(fread(fopen($binary_File, "r"), filesize($binary_File)));
$strDescription = addslashes($file_description);
$sql = "INSERT INTO binary_data_files ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binary_File_name', '$binary_File_size', '$binary_File_type')";
$result = mysql_query($sql, $db);
echo "The file was successfully added to our database.
";
echo "
File Name: ". $binary_File_name;
echo "
File Size: ". $binary_File_size ." bytes (approx ". ($binary_File_size/1024) ." KB)";
echo "
File Type: ". $binary_File_type;
}
mysql_close();
?>
Supposedly, this will get the info without any extra code. Can anyone tell me why mine doesn't work. What paramaters do I have to set or whatever
Thanx in advance