473,395 Members | 1,670 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,395 software developers and data experts.

store image blob in database joomla

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' );
$filename = JFile::makeSafe($file['img2']);
$src = $file['tmp_name'];
$image = mysql_escape_string(file_get_contents($file['img2']['tmp_name']));

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

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.
Jun 12 '10 #1
1 9446
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.

Manish Choudhary
Oct 12 '11 #2

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

Similar topics

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
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) {}...
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...
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...
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.
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'...
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, ...
by: selvasoft | last post by:
hi how to store image in database using JSP
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...
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>...
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...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.