473,216 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

File Fun

Ok, I'm mulling over different techniques to solve a problem, and
thought that insight from other PHP/MySQL gurus would be of value.

I'm weighing and experimenting with storing data in a MySQL database
instead of my usual file "cache". My normal technique for doing this
kind of interaction is to rename/store the file on a portion of the
server somewhere, and just store the path to the file in the DB.

In this particular case, I'm mostly working with images, and sometimes
it'd be nice to interact with them like they were data in the database,
though it's probably sometimes easier or more efficient to store them
on the server drive.

Securing the data is kind of a mixed bag... You can always store the
file in a non-servable portion of the drive and write a page to serve
it up to authorized users. This would require both a DB interaction and
a file read. If the data is in the DB, it'd save the file access (but
the data still has to be read from the HDD anyway). In either case, the
data read/serve is indirect (controlled by PHP).

The biggest advantage to storing the data in the database is
portability from one server to another. If the files are separate, you
have to deal with a mysql db, plus a bunch of other files, and make
sure the new system is pathed/secured correctly. If everything is part
of the DB, you really only have one file to worry about.

It's probably a lot more efficient to read the file directly off the
FS, instead out of a DB. I haven't seen any benchmarks showing HOW much
more efficient though. It's most likely significant.

I like the idea of being able to maintain all of my data in one place
(not having to do file system deletes/copies/etc). It also allows me to
do some pretty funky stuff like, run an update statement on my images
(in this case, not particularly practical, but it could be interesting
for working with things like evaluation routines in genetic
algorithms).

Are there pros or cons that I've missed? Has anyone actually TRIED it?
I've read about a 47kb limit problem that some people have. Anyone know
anything about this?

~D

Jul 17 '05 #1
1 1569
D,
Are there pros or cons that I've missed? Has anyone actually TRIED it?
I've read about a 47kb limit problem that some people have. Anyone know
anything about this?


Actually I am running a system where I store 3 different images in a
row. One large sizes, one medium sized, and one thumbnail.

Mine is a bit different. I cache all the queries and all pages on the
harddrive anyways. So therefore they are still in the database but get
pulled from a cache 98% of the time.

However with this technique I have found that it has been almost exactly
the same if not a bit faster than my previously tried routines.

When you read about it I think it all comes down to personal preference.
There are several ways to do it and advantages to both. I decided to
basically mix the two and have the full advantage :)

I also store files in the database as well, some disagree with this just
like images, but for the most part when they see the app they can't even
tell the difference. Most people are talking technically about what
should and shouldn't be done and why it would be bad. And just adopt it
when they hear it 400 times. Never hurts to try something once and
merge it to something else (just use oop so you can expand the original
class)

Mike
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
0
by: troutbum | last post by:
I am experiencing problems when one user has a document open through a share pointing to the web site. I use the dsolefile to read the contents of a particular directory and then display them in a...
0
by: thjwong | last post by:
I'm using WinXP with Microsoft Visual C++ .NET 69462-006-3405781-18776, Microsoft Development Environment 2003 Version 7.1.3088, Microsoft .NET Framework 1.1 Version 1.1.4322 SP1 Most developers...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.