| |
@Timofeev Noogle

Joined: 09 Aug 2005
102.00 GC$
Items
|
Posted: Thu Aug 11, 2005 5:49 am Post subject: get file info with PHP |
|
|
|
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.<P>";
echo "<P><B>File Name: </B>". $binary_File_name;
echo "<BR><B>File Size: </B>". $binary_File_size ." bytes (approx ". ($binary_File_size/1024) ." KB)";
echo "<P><B>File Type: </B>". $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 _________________ WebList, Miro Web Development, Content Management System, Linux & BSD Open Directory Project News
Online Feed Reader 1.0b |
|
| Back to top |
|
|
markkk Googler

Joined: 30 Jul 2005
1739.30 GC$
Items
|
Posted: Tue Aug 16, 2005 12:44 am Post subject: |
|
|
|
| Search for special function that displays file infos.. |
|
| Back to top |
|
|
JOKERz Riot of The Blood


Joined: 19 Aug 2005 Location: Grave 7905.25 GC$
Items
|
Posted: Fri Aug 19, 2005 6:04 am Post subject: |
|
|
|
| i think you need to get the file name first, then get the last three character from that file. |
|
| Back to top |
|
|
Sponsored Links
|
Posted: 5 Dec 2008 11:39 am Post subject: Advertisements |
|
|
|
|
|
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Host your free forums with Invision Plus.net forum web hosting with your own subdomain.
alexisBlue v1.2 // Theme Created By: Andrew Charron // Icons in Part By: Travis Carden
|
|
|
|
|