File Upload using Matronic Theme
First of All Create Table deposit_slips
-- phpMyAdmin SQL Dump
-- version 4.1.12
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 10, 2017 at 03:02 PM
-- Server version: 5.6.16
-- PHP Version: 5.5.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `money`
--
-- --------------------------------------------------------
--
-- Table structure for table `deposit_slips`
--
CREATE TABLE IF NOT EXISTS `deposit_slips` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`deposit_id` int(10) NOT NULL,
`file_name` varchar(30) NOT NULL,
`file_type` varchar(30) NOT NULL,
`file_size` int(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Then add Model.php file
<?php
App::uses('AppModel', 'Model');
/**
* DepositSlip Model
*
* @property Deposit $Deposit
*/
class DepositSlip extends AppModel {
/**
* Validation rules
*
* @var array
*/
public $validate = array(
'id' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'deposit_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'file_name' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'file_type' => array(
'extension' => array(
'rule' => array('extension',array('jpeg','jpg','png','gif')),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'file_size' => array(
'fileSize' => array(
'rule' => array('fileSize'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'Deposit' => array(
'className' => 'Deposit',
'foreignKey' => 'deposit_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
Then the Deposit Model is here
public $hasOne = array(
'DepositSlip' => array(
'className' => 'Emp_image',
'foreignKey' => 'deposit_id'
)
);
-- phpMyAdmin SQL Dump
-- version 4.1.12
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 10, 2017 at 03:02 PM
-- Server version: 5.6.16
-- PHP Version: 5.5.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `money`
--
-- --------------------------------------------------------
--
-- Table structure for table `deposit_slips`
--
CREATE TABLE IF NOT EXISTS `deposit_slips` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`deposit_id` int(10) NOT NULL,
`file_name` varchar(30) NOT NULL,
`file_type` varchar(30) NOT NULL,
`file_size` int(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Then add Model.php file
<?php
App::uses('AppModel', 'Model');
/**
* DepositSlip Model
*
* @property Deposit $Deposit
*/
class DepositSlip extends AppModel {
/**
* Validation rules
*
* @var array
*/
public $validate = array(
'id' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'deposit_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'file_name' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'file_type' => array(
'extension' => array(
'rule' => array('extension',array('jpeg','jpg','png','gif')),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'file_size' => array(
'fileSize' => array(
'rule' => array('fileSize'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'Deposit' => array(
'className' => 'Deposit',
'foreignKey' => 'deposit_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
public $hasOne = array(
'DepositSlip' => array(
'className' => 'Emp_image',
'foreignKey' => 'deposit_id'
)
);
After That
Comments
Post a Comment