PHPackages                             elic-dev/database-blob-file - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. elic-dev/database-blob-file

ActiveCakephp-plugin[Database &amp; ORM](/categories/database)

elic-dev/database-blob-file
===========================

Store uploads from cakephp as blob/binary in the database

2.x-dev(10y ago)21.5kMITPHPPHP &gt;=5.4.0

Since Feb 12Pushed 10y ago2 watchersCompare

[ Source](https://github.com/elic-dev/database-blob-file)[ Packagist](https://packagist.org/packages/elic-dev/database-blob-file)[ RSS](/packages/elic-dev-database-blob-file/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Database Blob File
==================

[](#database-blob-file)

This plugin is in a very early stage and should not be used for production environment.

Store your uploads from CakePHP form helper directly in the database as binary object.

If you still consider that all uploaded files **have to be** stored in the filesystem you can ignore this plugin.

Install
-------

[](#install)

This Plugin requires CakePHP 2.

### Enable Plugin

[](#enable-plugin)

Enable to plugin in your bootstrap.php file. Routes are required for serving uploaded files via http.

```
CakePlugin::load('DatabaseBlobFile', array(
	'routes'    => true,
	'bootstrap' => true,
));

```

### Create a BLOB column

[](#create-a-blob-column)

Change or add an column in your database as `MEDIUMBLOB` (max. 16MB file size).

### Add the behavior to your Model

[](#add-the-behavior-to-your-model)

Tell the Model to load the behavior for saving files directly.

```
public $actsAs = array(
	'DatabaseBlobFile.BlobFile' => array(
		'imageMaxWidth' => 1000,
	)
);

```

You can set addional parameters like:

`imageMaxWidth` Resize uploaded images to have a maximum width.

### Form

[](#form)

And make sure your form created with a correct type to allow file uploads at all.

```

```

Add your form field with the form helper

```

```

Using the plugin
----------------

[](#using-the-plugin)

Because it is not necessary to transfer all files with every database select every time the model returns only the uploaded file size in byte. This can be usefull to decide if something has been uploaded at all.

You will have a new virtual field containing a base path to the file (will be replaced with a View helper function) in your database result.

```
