473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

store image blob in database joomla

1
Hello,
I'm developping a new joomla component, so i want to store pictures in database table in field type : blob. i'm wondery how to proceed to do this.

I'm using this to get file from the form :

$file = JRequest::getVar( 'img2', null, 'files', 'array' );
jimport('joomla.filesystem.file');
$filename = JFile::makeSafe($file['img2']);
$src = $file['tmp_name'];
$image = mysql_escape_string(file_get_contents($file['img2']['tmp_name']));
$type_img=strtolower(JFile::getExt($file));

$db =& JFactory::getDBO();
$query = "UPDATE #__prifoot SET extension2='".$type_img."' WHERE id = '89' ";
$db->setQuery($query);
$db->query();

as you see in this step i want just to get extension of the file and store it in database for just for test, and when i check my database table jos_prifoot i have in the field extension2 null value!

it means that the method strtolower(JFile::getExt($file)) returns a null value. and i dont know why!! is the mistakes in the method JRequest::getVar( 'img2', null, 'files', 'array' ) which i'm using to get file?

Thank you.
hassal
Jun 12 '10 #1
1 9431
You have to convert image into byte array..

but I personally recommend not to store image in database as it will increase unnecessary traffic to your database server and can affect your site performance. So its better to store image somewhere in your web-space and store the path only to the database. Its just my opinion.

Thanks
Manish Choudhary
Oct 12 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Beruang | last post by:
Hi, How to load image from database MS SQL Server into PictureBox if I have Table called Student(StudID, Name, StudImage) StudImage data types is Image. Thanks
5
by: Dav | last post by:
Hi all, I am using these code to save Image to database: Dim fs As FileStream = New FileStream(filename, _ FileMode.OpenOrCreate, FileAccess.Read) Dim rawData() As Byte = New Byte(fs.Length) {}...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
0
by: Cezus | last post by:
Good day, Im a beginner at C# and i use the book Visual C# 2005: How to program from Deitel/Pearson. I want to build a simple Anime (movie) database. It contains a list box with all the anime...
1
by: shanmukha | last post by:
sir,we are doing STIGNOGRAPHY project.my problem is how to store picture in database table?i know only text,and number.
1
by: sana krishna | last post by:
Pls Help me-------------- I use ASP(C#.NET) and oracle. When i retrive image from database .it display error message... System.InvalidCastException: Unable to cast object of type 'System.DBNull'...
7
pradeepjain
by: pradeepjain | last post by:
hii, i have stored the images from form to database in blob format.now i have a necessity to retrieve image from database and store it in a folder ..how to do this.. thanks, ...
2
selvasoft
by: selvasoft | last post by:
hi how to store image in database using JSP
0
selvasoft
by: selvasoft | last post by:
Please any one help me i want store my image to oracle database am using JSP here is my code.But this code will return Null Pointer Error. What is wrong with this code. Am using HTML form to browse...
4
selvasoft
by: selvasoft | last post by:
Hi Please help me i want display all images from my database. but here my code that will display only one image from database. But i want all images, any one help me. <html> <head>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.