| View previous topic :: View next topic |
| Author |
Message |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Mon May 18, 2009 1:07 pm Post subject: image into db. |
|
|
Alot of ppl laught at me when I say I wanna insert image to db. I don't know why they so mean. It's nothing wrong with that, infact alot of large scales systems do it not to mention axapta.
So I want to insert an image to a db (blob, binary). What kind of datatype do I use? Most guides no intenet uses byte array but that seems strange becuase I doubt MySql would know what it is.
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
DanielG Expert Cheater
Reputation: 1
Joined: 13 May 2009 Posts: 130 Location: The Netherlands
|
Posted: Mon May 18, 2009 3:03 pm Post subject: |
|
|
We use MsSQL and there you have the 'old' type called 'image' which basicly is a binary type.
I think for MySQL you can best use binary, there is nothing really wrong in using it to store images, I doubt you will be using it for hundreds of users simutanously.
Although if you are using static images that get requested alot it seems a waste to use DB connections (and overhead) if you can just reffer to a location on the hard drive.
And a byte array is simply and array of bytes which can be any value (e.g. not just text but also binary), you'll need that to hold the data you want to send to the DB.
Which language are you using to 'talk' to the database? I bet there are alot of examples for every language of how to get an image into a database.
We use the C# InputStream method to put the image in a byte array and then use a parametered SQL query to put the byte array in the database.
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Tue May 19, 2009 4:00 am Post subject: |
|
|
blob is also binary. Also for me it's trying to send 'Byte[]' to db no good.
| Code: | | INSERT INTO Pictures (name, source) VALUES('salmon',System.Byte[]); |
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Tue May 19, 2009 4:28 am Post subject: |
|
|
You could save the image file on the server (in folder say... ~/images) and then in the DB you can have a link to that image...
_________________
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Tue May 19, 2009 4:38 am Post subject: |
|
|
| Localhost wrote: | | You could save the image file on the server (in folder say... ~/images) and then in the DB you can have a link to that image... |
Really? Is that what I asked for? I said I wanted to store the images binary in the db.
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
DanielG Expert Cheater
Reputation: 1
Joined: 13 May 2009 Posts: 130 Location: The Netherlands
|
Posted: Tue May 19, 2009 5:01 am Post subject: |
|
|
| wallantia wrote: | blob is also binary. Also for me it's trying to send 'Byte[]' to db no good.
| Code: | | INSERT INTO Pictures (name, source) VALUES('salmon',System.Byte[]); |
|
What language is this?
VB.NET?
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Tue May 19, 2009 6:24 am Post subject: |
|
|
| DanielG wrote: | | wallantia wrote: | blob is also binary. Also for me it's trying to send 'Byte[]' to db no good.
| Code: | | INSERT INTO Pictures (name, source) VALUES('salmon',System.Byte[]); |
|
What language is this?
VB.NET? |
c#
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 26004 Location: The netherlands
|
Posted: Tue May 19, 2009 6:25 am Post subject: |
|
|
Can't really help with this as I only have experience with using database specific classes that handle the binary fields as objects so no sql syntax used at all (most likely internally used but not at my, programmers, side)
Also, I don't know what the original poster's language is in. But, if it's php I may have a nice example that uses blob fields to store files in: Mantis bugtracker.
It's opensource so if you're using php and can't find information anywhere else, you can always try to figure out how mantis works
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
|
| Back to top |
|
 |
|