42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
/*
|
||
|
* Example PHP implementation used for the index.html example
|
||
|
*/
|
||
|
|
||
|
// DataTables PHP library
|
||
|
include("editor/lib/DataTables.php");
|
||
|
|
||
|
// Alias Editor classes so they are easy to use
|
||
|
use
|
||
|
DataTables\Editor,
|
||
|
DataTables\Editor\Field,
|
||
|
DataTables\Editor\Format,
|
||
|
DataTables\Editor\Mjoin,
|
||
|
DataTables\Editor\Options,
|
||
|
DataTables\Editor\Upload,
|
||
|
DataTables\Editor\Validate,
|
||
|
DataTables\Editor\ValidateOptions;
|
||
|
|
||
|
// Build our Editor instance and process the data coming from _POST
|
||
|
Editor::inst($db, 'company')
|
||
|
->fields(
|
||
|
Field::inst('id'),
|
||
|
Field::inst('code'),
|
||
|
Field::inst('name'),
|
||
|
Field::inst('holdings'),
|
||
|
Field::inst('logo')
|
||
|
->setFormatter( Format::ifEmpty( null ) )
|
||
|
->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/uploads/__NAME__' )
|
||
|
->db( 'files', 'id', array(
|
||
|
'filename' => Upload::DB_FILE_NAME,
|
||
|
'filesize' => Upload::DB_FILE_SIZE,
|
||
|
'web_path' => Upload::DB_WEB_PATH,
|
||
|
'system_path' => Upload::DB_SYSTEM_PATH
|
||
|
) )
|
||
|
->validator( Validate::fileSize( 50000000, 'Files must be smaller than 50MB' ) )
|
||
|
->validator( Validate::fileExtensions( array( 'jpg', 'jpeg', 'png' ), "Please upload PDF only" ) )
|
||
|
),
|
||
|
)
|
||
|
->process($_POST)
|
||
|
->json();
|