Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > PHP
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 10-28-2007, 01:48 AM   #1 (permalink)
Love.Oasis
banned
 
Join Date: Oct 2007
Posts: 21
Love.Oasis is on a distinguished road
Store Image in Database

I have the following code that uploads images to the server. How do I store the images in the database? What options do I have?

Code:
<?php if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/bmp") || ($_FILES["file"]["type"] == "image/pjpeg") && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
__________________
Love.Oasis is offline   Reply With Quote
Old 10-28-2007, 08:13 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,681
redhead is on a distinguished road
Quote:
How do I store the images in the database?
Code:
INSERT INTO foo (bar, baz, ...) VALUES ('qux', 'quux', ...);
Quote:
What options do I have?
Anything you want, it's your database.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead 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

vB 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
Change Image Love.Oasis HTML, XML, Javascript, AJAX 0 10-22-2007 10:13 AM
Xampp Database Store Salchester Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 1 03-23-2007 03:12 PM
PHP Image Database Salchester PHP 1 02-07-2007 06:12 AM
EnterpriseDB 2005 Wins Best Database Award at LinuxWorld technobard Code Newbie News 2 09-06-2005 07:41 PM
storing image in a database? Admin PHP 3 04-14-2003 10:40 AM


All times are GMT -8. The time now is 12:00 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle