https://github.com/thecodingmachine/mvc.bce.jquery-file-upload
This package contains a jQuery file upload based field descriptor and renderer for BCE. This will help you build forms with HTML5 file upload capabilities.
https://github.com/thecodingmachine/mvc.bce.jquery-file-upload
Last synced: 3 months ago
JSON representation
This package contains a jQuery file upload based field descriptor and renderer for BCE. This will help you build forms with HTML5 file upload capabilities.
- Host: GitHub
- URL: https://github.com/thecodingmachine/mvc.bce.jquery-file-upload
- Owner: thecodingmachine
- Created: 2014-04-30T08:52:11.000Z (about 12 years ago)
- Default Branch: 3.2
- Last Pushed: 2015-02-05T12:59:15.000Z (over 11 years ago)
- Last Synced: 2025-02-16T12:30:28.865Z (over 1 year ago)
- Language: PHP
- Homepage: https://mouf-php.com/packages/mouf/thecodingmachine/mvc.bce.mvc.bce.jquery-file-upload
- Size: 513 KB
- Stars: 0
- Watchers: 15
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
About the jQuery file upload descriptor and renderer for BCE
============================================================
BCE is a form builder for the [Mouf framework](http://mouf-php.com).
This package contains classes enabling the use of the **jQuery file upload** plugin right into forms generated by BCE.
How to use it
-------------
###Single file uploads:
TODO
###Multi file uploads:
If you want to upload multiple files associated to a bean, it is likely you have a database table containing the list of files.
For instance, if you have a form representing a product, and if the product can have many photos attached to it, you certainly have a "products" table and a "product_photos" table that points towards product. Therefore, you probable have a `ProductPhotoDao` and `ProductPhotoBean` class.
The first thing to do is this:
- `ProductPhotoDao` (the DAO of the table that contains the list of files) should implement the `FileDaoInterface`
- `ProductPhotoBean` (the Bean of the table that contains the list of files) should implement the `FileBeanInterface`
####FileDaoInterface
```php
interface FileDaoInterface extends DAOInterface {
/**
* Returns a list of beans implementing the FileBeanInterface associated with the main bean containing the files.
*
* @param TDBMObject $mainBean
*/
function findFiles($mainBean);
}
```
The `findFiles` method will return the list of beans of the "file" table. If you are using TDBM, a typical implementation is:
```php
public function findFiles($mainBean) {
// Returns a list of FileBeanInterface associated to $mainBean
return $this->getListByFilter($mainBean);
}
```
####FileBeanInterface
```php
interface FileBeanInterface {
/**
* Returns the full path to the file.
*/
function getFullPath();
/**
* Sets the name of the file to be stored.
*
* @param string $fileName
*/
function setFileName($fileName);
/**
* Sets the main bean we are pointing to.
*
* @param TDBMObject $mainBean
*/
function setMainBean($mainBean);
}
```
Please note that `getFullPath` should return the complete path to the file stored on disk on the server.
`setFileName` is only setting the name of the file (not the path). Finally `setMainBean` is setting the
object the file is related to. In our exemple, that would be an instance of `ProductBean`.
Are you done? Well, now, implementing the jQueryFileUpload mechanism should be a breeze!
Go to your `BCEForm` in instance mode, and in the list of `fieldDescriptors`, drag'n'drop a
`JqueryUploadMultiFileFieldDescriptor`.

Now, configure the instance you just drag'n'dropped:
