Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2003, 03:27 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Picture to MySQL

I wanna ask how can we upload picture to database?

 
Old July 9th, 2003, 03:05 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you successfully been able to upload files to your webserver? If not, there's a tutorial in the PHP manual online:
  http://www.php.net/features.file-upload

If you're just having problem inserting the file data into a database, I suggest you read this similar thread:
  http://p2p.wrox.com/topic.asp?TOPIC_ID=1495


Take care,

Nik
http://www.bigaction.org/
 
Old July 10th, 2003, 03:45 AM
Registered User
 
Join Date: Jul 2003
Location: , , Netherlands.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would like to suggest you rethink your strategy. I'm assuming you're using MySQL for your database (as most PHP programmers tend to use this). Databases aren't built for storing binary data in this way and, if you're expecting any decent amount of traffic, it may even noticably slow down your site.

This is what filesystems are made for.

I'd suggest storing a pathname to the actual image in the database, and then either:

a) doing a header('Content-type: image/image-type'); passthru($path_to_image); (this only if the images are outside your web document root). This script would then be referenced in an img tag.

or

b) storing the paths as relative to your web document root and including them in img tags.



Kind regards,


Devon H. O'Dell
sitetronics.com
 
Old July 11th, 2003, 03:50 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Germany.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Devon,
Quote:
quote:
Databases aren't built for storing binary data in this way and, if you're expecting any decent amount of traffic, it may even noticably slow down your site.
I would agree to a certain degree. There are also advantages to this approach.

You don't have to deal with inconsistencies when storing in a db.
You have better access control.
It seems to be in line with relational db theory

I don't know if this can be applied fully for MySQL, but an in depth explanation of using BLOB's in a DB (MS SQL Server) can be found here

http://www.microsoft.com/technet/tre...art3/c1161.asp

Have fun!

Cheers,
Frank




Similar Threads
Thread Thread Starter Forum Replies Last Post
Picture Box harfani VB.NET 2002/2003 Basics 0 August 6th, 2007 08:36 AM
How to upload a picture grstad Classic ASP Databases 5 February 28th, 2006 02:20 PM
inserting picture p_gauri7 Crystal Reports 1 February 21st, 2005 07:25 AM
picture rajuru PHP Databases 1 October 18th, 2004 08:56 PM
OLE picture - accessing the picture property bdcrisp Excel VBA 0 December 7th, 2003 09:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.