php-windows Digest 11 May 2012 15:19:15 -0000 Issue 4041

Topics (messages 30873 through 30877):

Re: Alternative methods for storing uploaded images?
        30873 by: Gavin Chalkley
        30874 by: Jacob Kruger
        30875 by: Carl Roett
        30876 by: Jacob Kruger

Friday afternoon error/issue
        30877 by: Jacob Kruger

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Jacob,

I have a gallery i created with a Java template, PHP, and MYSQL.

In the admin section you create category's and upload the images to a folder
eg: Pictures

On upload the script water marks and creates Thumb nails for use in the
gallery.

http://www.helenshappyhome.co.uk/gallery.php

Visitors can then select what gallery they wish to view, and the PHP pulls
the relevant images

Before i did this, i did a lot of looking into it and was advised using the
DB to store the image/binary would be a big no on performance of the site. I
do not know how true this is.


BR,

Gav
Skype : squidge1980

-----Original Message-----
From: Jacob Kruger [mailto:jac...@mailzone.co.za] 
Sent: 10 May 2012 19:08
To: php-wind...@lists.php.net
Subject: [PHP-WIN] Alternative methods for storing uploaded images?

Just wondering if it's better to either store uploaded images, via something
like a form of CMS, in a static folder, with a unique name based on
something like the data record's id field, when keeping track of it's
location like that, or is it better to actually store the binary data of the
image file in the mySQL database itself, and then sort of stream it back out
when displaying the image, and if so, would presume that would be relatively
simple to implement, but, OTOH, if you were then using the data to then
render static content output for later use, it would, obviously, be better
to keep the image content static as well...?

Thoughts/examples?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'


--- End Message ---
--- Begin Message --- Definitely makes sense with regard to site performance, but, sort of in past used something like this in ASP.Net to sort of/partially make sure only signed in users/browsers could then actually 'see' images, etc., but, that could also be handled easily enough using a form of server-side redirect/reroute, etc., and, main thing is was just wondering about it, but, for now, am definitely quite content/happy enough renaming image files and then using the static content/files later on.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Gavin Chalkley" <gavin.chalk...@gmail.com>
To: "'Jacob Kruger'" <jac...@mailzone.co.za>; <php-wind...@lists.php.net>
Sent: Thursday, May 10, 2012 8:35 PM
Subject: RE: [PHP-WIN] Alternative methods for storing uploaded images?


Jacob,

I have a gallery i created with a Java template, PHP, and MYSQL.

In the admin section you create category's and upload the images to a folder
eg: Pictures

On upload the script water marks and creates Thumb nails for use in the
gallery.

http://www.helenshappyhome.co.uk/gallery.php

Visitors can then select what gallery they wish to view, and the PHP pulls
the relevant images

Before i did this, i did a lot of looking into it and was advised using the DB to store the image/binary would be a big no on performance of the site. I
do not know how true this is.


BR,

Gav
Skype : squidge1980

-----Original Message-----
From: Jacob Kruger [mailto:jac...@mailzone.co.za]
Sent: 10 May 2012 19:08
To: php-wind...@lists.php.net
Subject: [PHP-WIN] Alternative methods for storing uploaded images?

Just wondering if it's better to either store uploaded images, via something
like a form of CMS, in a static folder, with a unique name based on
something like the data record's id field, when keeping track of it's
location like that, or is it better to actually store the binary data of the image file in the mySQL database itself, and then sort of stream it back out when displaying the image, and if so, would presume that would be relatively
simple to implement, but, OTOH, if you were then using the data to then
render static content output for later use, it would, obviously, be better
to keep the image content static as well...?

Thoughts/examples?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'



--- End Message ---
--- Begin Message ---
The answer is "it depends" and in some very specialized situations storing
binaries in the database might be the best solution. But in general, this
approach will cause you serious problems.

Some ramifications:

1) Browsers won't cache the images. So you'll take a CPU and bandwidth hit
every time
2) MySQL stores encoded binary data in a separate part of the database.
Your files probably won't get held in the memory cache. So each file load
carries the same penalty as a loading the raw file from disk.
3) It will make your database huge. Which will make it very challenging to
import, export, and move between test servers. Its easy to write scripts
that can handle content files that are missing from the server, but a
database is an atomic "all or nothing" thing.
4) Makes it difficult to manually edit things in the database.

My team is building a huge (hundreds of thousands of LOC) image management
plugin for WordPress. Have a look at our code and see how we solve these
problems. Specifically, look at the disk cache classes.

http://code.google.com/p/buddypress-media/source/browse/#svn%2Fbp_media%2Ftrunk


^C^

==================================

On Thu, May 10, 2012 at 12:07 PM, Jacob Kruger <jac...@mailzone.co.za>wrote:

> Just wondering if it's better to either store uploaded images, via
> something like a form of CMS, in a static folder, with a unique name based
> on something like the data record's id field, when keeping track of it's
> location like that, or is it better to actually store the binary data of
> the image file in the mySQL database itself, and then sort of stream it
> back out when displaying the image, and if so, would presume that would be
> relatively simple to implement, but, OTOH, if you were then using the data
> to then render static content output for later use, it would, obviously, be
> better to keep the image content static as well...?
>
> Thoughts/examples?
>
> Stay well
>
> Jacob Kruger
> Blind Biker
> Skype: BlindZA
> '...fate had broken his body, but not his spirit...'
>

--- End Message ---
--- Begin Message ---
All makes good sense.

Will check out code, etc.

Thanks

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Carl Roett" <carlro...@gmail.com>
To: <php-wind...@lists.php.net>
Sent: Thursday, May 10, 2012 11:41 PM
Subject: Re: [PHP-WIN] Alternative methods for storing uploaded images?


The answer is "it depends" and in some very specialized situations storing
binaries in the database might be the best solution. But in general, this
approach will cause you serious problems.

Some ramifications:

1) Browsers won't cache the images. So you'll take a CPU and bandwidth hit
every time
2) MySQL stores encoded binary data in a separate part of the database.
Your files probably won't get held in the memory cache. So each file load
carries the same penalty as a loading the raw file from disk.
3) It will make your database huge. Which will make it very challenging to
import, export, and move between test servers. Its easy to write scripts
that can handle content files that are missing from the server, but a
database is an atomic "all or nothing" thing.
4) Makes it difficult to manually edit things in the database.

My team is building a huge (hundreds of thousands of LOC) image management
plugin for WordPress. Have a look at our code and see how we solve these
problems. Specifically, look at the disk cache classes.

http://code.google.com/p/buddypress-media/source/browse/#svn%2Fbp_media%2Ftrunk


^C^

==================================

On Thu, May 10, 2012 at 12:07 PM, Jacob Kruger <jac...@mailzone.co.za>wrote:

Just wondering if it's better to either store uploaded images, via
something like a form of CMS, in a static folder, with a unique name based
on something like the data record's id field, when keeping track of it's
location like that, or is it better to actually store the binary data of
the image file in the mySQL database itself, and then sort of stream it
back out when displaying the image, and if so, would presume that would be relatively simple to implement, but, OTOH, if you were then using the data to then render static content output for later use, it would, obviously, be
better to keep the image content static as well...?

Thoughts/examples?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'




--- End Message ---
--- Begin Message ---
This is, for whatever reason, something I keep on typing incorrectly on quite a 
few pages - strange, but funny, and now, I pretty much realise immediately 
what's wrong when encounter error/issue on newish pages:

$mysqliObj = new mysqli("$dbHost, $dbUser, $dbPass, $dbDB);

All those variables are defined/assigned in a single file called dbInc.php 
which means can set/change variable values relating to host, user name, 
password, and table names etc. in one place, but anyway...<smile>

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

--- End Message ---

Reply via email to