Google Community
Latest Forums Rules Resources
Custom Search

Go Back   Google Community > Webmaster Forums > Web Design, Coding & Programming Forum

GoogleCommunity Sponsor
Cirtex Hosting
Use coupon "forum" for 50% Off!

Reply
 
LinkBack Thread Tools Display Modes
Old 08-11-2005, 05:49 AM   #1 (permalink)
Noogle
 
Join Date: Aug 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
@Timofeev
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.

"; 
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
@Timofeev is offline   Reply With Quote
 
Sponsored Links
Old 08-16-2005, 12:44 AM   #2 (permalink)
Googler
 
Join Date: Jul 2005
Posts: 99
Thanks: 0
Thanked 1 Time in 1 Post
markkk
Search for special function that displays file infos..
markkk is offline   Reply With Quote
Old 08-19-2005, 06:04 AM   #3 (permalink)
Master Googler
 
JOKERz's Avatar
 
Join Date: Aug 2005
Location: Grave
Posts: 558
Thanks: 0
Thanked 0 Times in 0 Posts
JOKERz
i think you need to get the file name first, then get the last three character from that file.
JOKERz is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i upload a file h4mza General Discussion 4 10-22-2006 01:52 PM
File transfer aijaz Google Talk 2 09-21-2006 03:59 AM
Editing a php file Anita Web Design, Coding & Programming Forum 3 06-20-2006 03:53 PM
Which file extension are u? Orpheus Chit Chat 35 10-25-2005 09:58 PM
File upload with PHP puccavn Web Design, Coding & Programming Forum 0 05-05-2005 11:41 PM


All times are GMT -8. The time now is 05:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© 2004–2007 Google Community