473,909 Members | 2,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1595
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
3939
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 them a caption, storing the caption and filename in a text file. It's a bit buggy when removing the photos and captions from the file, and also in displaying them on the delete page. you can see it in action at www.4am.com.au/gallery/upload.php...
5
5475
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. I want to develop a webpage where people can send attachments that are stored on their local PC.
7
3546
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. How do i make the last pointer in the indirect sector that has another level of indirect pointer, and be defined recursively to support infinite large files? -code-
3
26280
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
0
3956
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. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
13
4340
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 that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
1
5436
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 completely/succsessfully on the client's computer before updating some metadata on the server (file downloaded date for instance) However, All examples i have tried, and all examples I have found that other people says works - doesn't work for me :-(
3
3178
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 I find a list of all the types which can be returned? For example, if it is a Word document will it return "document/doc".
0
2582
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 datalist. When the next user selects trys to run the page, the page fails and I get a generic error message from the stack trace. I am assuming that the document properties cannot be read when a file is open, but it worked well in asp. ...
0
2041
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 said to me that they have no problem doing that, but the following project file is said to be corrupted while opening in the IDE, it is the project file of NT xemacs BETA 21.5.24, http://ftp.xemacs.org/pub/beta/xemacs-21.5.24.tar.gz (under the...
0
11348
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10921
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10540
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9727
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8099
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7249
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5938
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3359
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.