Hi!
Basically, what I'm trying to do is a site for online storage of my own files, like Microsofts SkyDrive service. One thing I'm wondering about is what way that would be most effective to organize the files? My first thought was that when I upload the files to the server I also register the files in a database where I save all the information needed (location, file name, url etc.). With that information I can easily make all the necessary links and such that I need to obtain the files. I figured this must be faster than check the contents of every folder and then print out the file information from there. But if I skip the database it will be much easier handling the files and there will be no need to change the stored information when I move files around.

So what puts less weight on the server? Should I go through the hassle with the database, and if I do, do I gain any server efficiency from that?

Thanks!

i recommend you use database to store information of your files... it's a more professional approach.

i recommend you use database to store information of your files... it's a more professional approach.

But isn't it just as effective to just get all the information from reading the directory and the file information?

One benefit to using a database is that you would be able to set permissions and things such as shared files etc and hidden files. But you would also be able to have more detailed information about the files such as descriptions for each of them. If those options are not necessary to you then you should probably just use the information from the file system as it is easier. However I am not sure that it is any less strain on the server as if it is a hosting provider then many hosts have dedicated database servers and so it would be work spread over many processors instead of just a lot of strain on the one webserver process.

Im not an expert and these are just opinions so use them however you wish but let us know what you decide to do.

ParkeyParker

Member Avatar for diafol

With DB, you can give files faux names and locations. You could just name files: fileX.ext where the 'ext' is the true extension of the file and X can relate to the file's id within the db. This means that you can save all files within the same folder without any danger of overwriting etc.

So:
files table
id (Primary Key etc)
filename (actual physical name on server)
author (Foreign Key??)
ext (e.g. jpg, gif, pdf etc)
faux_file (false name or alias)
faux_folder (false path)
status (hidden, protected etc)
size
title
description
date_created
date_last_modified
(etc)

when file uploaded:
enter all file details to DB except physical filename
get ID via mysql_insert_id()
enter DB physical filename and rename physical file to fileX.ext
[X = id, ext = from db]

This is off top of my head, bet it could be made smoother with a bit of thinking.

You can search effectively as opposed to iterating over disparate folders - yuk. It also offers functionality w.r.t protecting document location.

One benefit to using a database is that you would be able to set permissions and things such as shared files etc and hidden files. But you would also be able to have more detailed information about the files such as descriptions for each of them. If those options are not necessary to you then you should probably just use the information from the file system as it is easier. However I am not sure that it is any less strain on the server as if it is a hosting provider then many hosts have dedicated database servers and so it would be work spread over many processors instead of just a lot of strain on the one webserver process.

Im not an expert and these are just opinions so use them however you wish but let us know what you decide to do.

ParkeyParker

That's true, I think I will be working with a database then. After all, you can save much more information then :) Thanks for the replies!

then mark this thread solved then.... marking thread solved is a way of saying thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.