Google Community Chat
 
get file info with PHP

You're visiting Google Community as a guest.
In order to post, you'll need to register and log in.



(If you were registered and logged in, these advertisements wouldn't be here)
Post new topic   Reply to topic    Google Community Forum Index // Web Design, Coding & Programming Forum
   
Author Message
@Timofeev
Noogle
Noogle


Joined: 09 Aug 2005

102.00 GC$

Items

PostPosted: Thu Aug 11, 2005 5:49 am    Post subject: get file info with PHP Reply with quote
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
View user's profile Send private message Visit poster's website
markkk
Googler
Googler


Joined: 30 Jul 2005

1739.30 GC$

Items

PostPosted: Tue Aug 16, 2005 12:44 am    Post subject: Reply with quote
Search for special function that displays file infos..
Back to top
View user's profile Send private message Visit poster's website
JOKERz
Riot of The Blood
Master Googler


Joined: 19 Aug 2005
Location: Grave
7905.25 GC$

Items

PostPosted: Fri Aug 19, 2005 6:04 am    Post subject: Reply with quote
i think you need to get the file name first, then get the last three character from that file.
Back to top
View user's profile Send private message
Sponsored Links
Posted: 5 Dec 2008 11:39 am    Post subject: Advertisements
Back to top
Post new topic   Reply to topic    Google Community Forum Index // Web Design, Coding & Programming Forum All times are GMT - 8 Hours
Page 1 of 1


 
Jump to:  
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

© 2005-2006 Google Community

Powered by phpBB

Privacy Policy | Contact Us

Powered by Google Search blog

This website is not affiliated in any way with Google, Inc.
Google™ is a registered trademark of Google, Inc.