CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 storing image in mysql

Print topic Send  topic

Author Message
sneakers

Posts: 13
Posted: 07/22/2004, 7:54 AM

I am storing an image in a mysql database field.
I know how to program this via regular php but am
having trouble trying to do this via code charge.
Here's my form:

  
<!-- BEGIN Record agent_photo -->  
<form name="{HTMLFormName}" action="{Action}" method="post" enctype="multipart/form-data">  
<input type="file" size="50" name="{photo_Name}">  
<!-- BEGIN Button Button_Insert --><input type="submit" value="Add" name="{Button_Name}"><!-- END Button Button_Insert -->  
 <input type="hidden" value="{MAX_FILE_SIZE}" name="{MAX_FILE_SIZE_Name}">  
</form>  
<!-- END Record agent_photo -->  

Here's the php code that I would use normally for the insert:
  
$photo_data = addslashes(fread(fopen($photo, "r"), filesize($photo)));  
$result=MYSQL_QUERY("INSERT INTO tbl_agent_photo (photo_bin_data) VALUES ($photo_data) " );  

My question is how to get this to work as a custom insert?

Any help would be appreciated.
View profile  Send private message
Damian
Posted: 07/22/2004, 4:07 PM

Why are you storing the image in the database?
It seems that most people store the image location and name in the database
but store the image itself in the file system.
Reasons?
Apparently it uses less resources this way - CPU and RAM, and your database
size ilaso limited to either 2 or 4GB on a 32bit platform.

Codecharges plugin does it to the file system.

Damian


"sneakers" <sneakers@forum.codecharge> wrote in message
news:540ffd52739f91@news.codecharge.com...
> I am storing an image in a mysql database field.
> I know how to program this via regular php but am
> having trouble trying to do this via code charge.
> Here's my form:
>
>
  
> <!-- BEGIN Record agent_photo -->  
> <form name="{HTMLFormName}" action="{Action}" method="post"  
> enctype="multipart/form-data">  
> <input type="file" size="50" name="{photo_Name}">  
> <!-- BEGIN Button Button_Insert --><input type="submit" value="Add"  
> name="{Button_Name}"><!-- END Button Button_Insert -->  
>  <input type="hidden" value="{MAX_FILE_SIZE}" name="{MAX_FILE_SIZE_Name}">  
> </form>  
> <!-- END Record agent_photo -->  
> 
>
> Here's the php code that I would use normally for the insert:
>
  
> $photo_data = addslashes(fread(fopen($photo, "r"), filesize($photo)));  
> $result=MYSQL_QUERY("INSERT INTO tbl_agent_photo (photo_bin_data) VALUES  
> ($photo_data) " );  
> 
>
> My question is how to get this to work as a custom insert?
>
> Any help would be appreciated.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Walter Kempees
Posted: 07/23/2004, 2:39 AM

The subject here is storing images in a database table.
Suppose we are not talking about images but eg. Word documents, scanned
images like passports, excel spreadsheets and so on.
Also suppose we are building a groupware solution, where members of a team
can supply each other with documents needed in a project.

It would of course be possible to store everything on file system level, but
speed would be served if team members are working on a world/global level.
Most important, at least to me, is security, it's much harder to crack a
database and subtract documents, than cracking a server and downloading
parts of a file system.

Talking about speed and size, try this
http://www.chiptuning.nl/731235/index.php
It is a commercial application, build by us for one of our customers.
The customer has a web application that enables him to maintian all the data
in the databse, on his site www.rica.nl (chiptuning) this info is
publicized.
All his dealers have personalized versions of this software.
How do we like the speed? Cars pictures come from the database as do the
power and torque curves.
Plse comment ! (using LAMP Linux Apache MySql PhP, not win32) actually MySql
is one of the fastest Internet DB's around.

Am in the process of porting the óld'maintenance shell to CCS, whereby the
upload and storage will come up next week, so expect an answer soon.

Walter
"Sometimes Q&D outperformes R&D"



"sneakers" <sneakers@forum.codecharge> schreef in bericht
news:540ffd52739f91@news.codecharge.com...
> I am storing an image in a mysql database field.
> I know how to program this via regular php but am
> having trouble trying to do this via code charge.
> Here's my form:
>
>
  
> <!-- BEGIN Record agent_photo -->  
> <form name="{HTMLFormName}" action="{Action}" method="post"  
> enctype="multipart/form-data">  
> <input type="file" size="50" name="{photo_Name}">  
> <!-- BEGIN Button Button_Insert --><input type="submit" value="Add"  
> name="{Button_Name}"><!-- END Button Button_Insert -->  
>  <input type="hidden" value="{MAX_FILE_SIZE}" name="{MAX_FILE_SIZE_Name}">  
> </form>  
> <!-- END Record agent_photo -->  
> 
>
> Here's the php code that I would use normally for the insert:
>
  
> $photo_data = addslashes(fread(fopen($photo, "r"), filesize($photo)));  
> $result=MYSQL_QUERY("INSERT INTO tbl_agent_photo (photo_bin_data) VALUES  
> ($photo_data) " );  
> 
>
> My question is how to get this to work as a custom insert?
>
> Any help would be appreciated.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

sneakers

Posts: 13
Posted: 07/23/2004, 5:24 AM

My question seems to have generated some discussion on why I'm storing images. I have my reasons and don't want to spend my time explaining why. I would still like to know how to get Code Charge to do this.

I have tried a number of ways to code this but Code Charge seems to keep dropping the values from $_FILES.

If anyone has an answer or suggestion, I would really appreciate it.
View profile  Send private message
Damian
Posted: 07/25/2004, 5:13 PM

I dont think Code Charge supports it.

"sneakers" <sneakers@forum.codecharge> wrote in message
news:541010393807ae@news.codecharge.com...
> My question seems to have generated some discussion on why I'm storing
images. I
> have my reasons and don't want to spend my time explaining why. I would
still
> like to know how to get Code Charge to do this.
>
> I have tried a number of ways to code this but Code Charge seems to keep
> dropping the values from $_FILES.
>
> If anyone has an answer or suggestion, I would really appreciate it.
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Walter Kempees
Posted: 07/26/2004, 4:35 AM

I will come back, am trying to build this myself.
Approach will be:
Standard file upload in a form, let it do what is does which is as far as i
can see now:
handle all the upload logic, storing the uploaded file name in a colum in
the table.
The on the server side actions I am going to add the standard code for
reading a file into a column, as stated already
addslashes(fread(fopen($photo, "r"), filesize($photo)));
substituting $photo with the filename value as stored.

In fact it is integrating external code because it would be possible to
autolink to a piece of php code doing this.
Walter

Sideline: I did manage to display the photo form a database in a ccs
generated form by using external php.
screenshot attached.
three images displayed all from the 1 database table (dumb approach but
previous designer built the table and it's widely used)
see previous link in this thread for performance



"sneakers" <sneakers@forum.codecharge> schreef in bericht
news:541010393807ae@news.codecharge.com...
> My question seems to have generated some discussion on why I'm storing
images. I
> have my reasons and don't want to spend my time explaining why. I would
still
> like to know how to get Code Charge to do this.
>
> I have tried a number of ways to code this but Code Charge seems to keep
> dropping the values from $_FILES.
>
> If anyone has an answer or suggestion, I would really appreciate it.
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
rtry
Posted: 09/10/2004, 2:37 AM

http://forums.codecharge.com/newtopic.php?forum_id=5
Add new topicjavascript:subscribe(49663,5)
Subscribe to topic
cherbert
Posted: 09/13/2004, 5:47 AM

Quote Damian:
Apparently it uses less resources this way - CPU and RAM, and your database
size ilaso limited to either 2 or 4GB on a 32bit platform.

Damian

MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the MyISAM storage engine in MySQL 3.23, the maximum table size was increased to 8 million terabytes (2 ^ 63 bytes). With this larger allowed table size, the maximum effective table size for MySQL databases now usually is determined by operating system constraints on file sizes, not by MySQL internal limits
cherbert
Posted: 09/13/2004, 5:51 AM

....and the Windows Server family has a file size limit of 16 exabytes (or 18,446,744,073,709,551,616 bytes) when installed using NTFS file system.
Karsten


Posts: 57
Posted: 09/27/2004, 5:19 PM

LOL

this is really funny thread

storing a bitmap or whatever file binary into a database is nonsense.
over time filesystem will be a 100s later a 1000s faster than the database "bitmapstorage-solution"
sorry but i have to ROFL

my personal opinion, only noobs store images binary in database (typical noob issue)

use filesystem or you need soon 8473034083 MB RAM :-D
sorry

Karsten from Germany


_________________
If one gives up, he told himself he failed.
View profile  Send private message
Don Safar
Posted: 09/28/2004, 8:45 AM

Karsten is correct. As a consultant, I have been confronted with this issue
more than once. Those that did not heed my advice soon found they were
having performance issues when trying to import or retrieve their images.

"Karsten" <Karsten@forum.codecharge> wrote in message
news:54158adfc5d5ff@news.codecharge.com...
> LOL
>
> this is really funny thread
>
> storing a bitmap or whatever file binary into a database is nonsense.
> over time filesystem will be a 100s later a 1000s faster than the database
> "bitmapstorage-solution"
> sorry but i have to ROFL
>
> my personal opinion, only noobs store images binary in database (typical
noob
> issue)
>
> use filesystem or you need soon 8473034083 MB RAM :-D
> sorry
>
> Karsten from Germany
>
>
> _________________
> If one gives up, he told himself he failed.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Natalia
Posted: 10/11/2004, 11:17 AM

It is matter of the coder if he wants to store files in database or whererer.... I think database designers also have their own reasons to create blob fields support in their engines.

Could any of you guys hit an idea how the guy would have deal with the problem he was dealing (manage to store the file in the database instead the filesystem) .....
lvalverdeb

Posts: 299
Posted: 10/11/2004, 4:13 PM

Hi,

http://www.phpbuilder.com/columns/florian19991014.php3 has a solution for uploading images to a database. Yet, the thread which followed that posting pretty much points to the same drawbacks discussed here.

Hope it helps

Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
dataobjx


Posts: 181
Posted: 10/12/2004, 4:52 AM

Issue #3 (October 2004) of CCS Developer Magazine will have part 1 of the DataObjx Document Management System for PHP. Based on the .ASP version, but converted to PHP the methods demonstrated will allow you to upload binary files to a database... the PHP example uses MySQL.

If you're not a registered member on www.dataobjx.net, please register now so that you will be notified when issue #3 is released (soon). Registration is Free and only requires a User Name/Nick Name, valid email address and password. You can also download issue #1 for FREE.

In addition, be sure you visit the 'Resources/Tools' area and download SQL Formatter (.asp and .php versions available) as well as any of the other files located there.

We look forward to seeing you on-line.
_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message
sneakers

Posts: 13
Posted: 10/12/2004, 5:03 AM

You can stop with the replies. I have found my own solution that works in CodeCharge. And it works quite well, thank you very much.

And Karsten, You should probably refrain from calling people names. It's not very becoming. My table contains only 19 images and is only 85k in size. I have end-users maintaining this data and they have no idea how to name files using the local file system. It's much easier to store a small number of images as in a database.

Geez, I think this may be the last time I ask for any help on this forum.
View profile  Send private message
g
Posted: 11/19/2004, 2:29 PM

You're a noob, whatever that is. Storing binary data in databases is perfectly acceptable. Maybe you worked on older systems. So postgres and oracle developers who store blobs are noobs.? You haven't a design clue....

And "sorry" , but I think you are a pedantic fool.




Quote Karsten:
LOL

this is really funny thread

storing a bitmap or whatever file binary into a database is nonsense.
over time filesystem will be a 100s later a 1000s faster than the database "bitmapstorage-solution"
sorry but i have to ROFL

my personal opinion, only noobs store images binary in database (typical noob issue)

use filesystem or you need soon 8473034083 MB RAM :-D
sorry

Karsten from Germany


mrachow


Posts: 509
Posted: 11/19/2004, 11:10 PM

That anew awaking of the thread reminded that I wanted to post here.

To retrieve the image use an absolute stripped down page (with nothing on it). At event AfterInitialize say
$DBConnection1 = new clsDBConnection1();

header ("Content-type: image/jpeg");
header ("Pragma: no-cache");
echo CCDLookUp("pic", "AccPic", "ACC_ID = " . CCGetSession("PicID"), $DBConnection1);

In this case the ID of the image is stored in a session variable. Of course this is an example only.

Fortunately CCDLookUp doesnt care about the type of data it retrieves. So it's not converted to String like in CodeCharge.

If you will see a small bar of your image only there should be a max for the size of retrieved data as I know for sure for db_odbc.php delivered by CC Studio (odbc_longreadlen).

Regards,
Michael
_________________
Best regards,
Michael
View profile  Send private message
mrachow


Posts: 509
Posted: 11/20/2004, 1:17 AM

What I forgot completely
This scipt have to be set as src of the HTML image tag e.g.
<IMG src='GetImage.php' ...

CU,
Michael
_________________
Best regards,
Michael
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.