Jump to content
xisto Community
Variablez

How To Add Files To My Sql Database

Recommended Posts

Although not advised for storing large files, you can include files directly into mysql by using the BLOB type. Unfortunately mysql databases normally don't have very much space allocated to them because they mostly store text so you might find that it is easier to upload files to a directory on your website and reference them from sql. If you are still sure you want to do this, and if you are trying to do this from php, this tutorial might help you on your way.

Share this post


Link to post
Share on other sites

I am Alpha testing a CMS that stores the Template file and the CSS file in a Database and allows changes to be made to them via the Admin Panel for the CMS instead of using an FTP program and an editor.
How cool is that?

So, storing files as a Database record is easy enough to do.
Here is the SQL for the Templates Table. You can add Templates and select whichever one you have added as the displayed Template via the Admin Panel.
The CSS files are handled the same, except in a different Table.

CREATE TABLE IF NOT EXISTS `templates` (  `id` int(11) NOT NULL auto_increment,  `name` varchar(100) NOT NULL,  `template` longtext,  `main_temp` char(3) NOT NULL default 'YES',  `css` varchar(8) default NULL,  PRIMARY KEY  (`id`));
The 'template' element of the Table stores the actual, full html as type=longtext.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.