Jquery图像裁剪
我在我的ci项目中使用了Jquery图像裁剪插件,但在这里我遇到了php文件中的问题。而我在构造中加载模型显示未定义的错误。
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Cropavatar extends CI_Controller {
private $src;
private $data;
private $dst;
private $type;
private $extension;
private $msg;
function __construct($src, $data, $file) {
$this -> setSrc($src);
$this -> setData($data);
$this -> setFile($file);
$this -> crop($this -> src, $this -> dst, $this -> data);
$this->load->model('file_manager_model', 'file_manager');
}
above is my code and here showing below error
遇到PHP错误
严重性:注意
消息:未定义属性:Cropavatar :: $ load
文件名:controllers / cropavatar.php
行号:20
注意:我是从这里引用的
FILTER_VALIDATE_BOOLEAN
答案 0 :(得分:0)
将from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class user_files(models.Model):
Filename = models.CharField(max_length=50)
Browse = models.FileField()
Username = models.ForeignKey(User,default=1)
放入crop.php
文件夹,
并在您的控制器加载库中
libraries
参考: https://codeigniter.com/user_guide/general/creating_libraries.html
和课堂上($this->load->library('crop');
)
修改自:
crop.php
要强>
function __construct($src, $data, $file) {
$this -> setSrc($src);
$this -> setData($data);
$this -> setFile($file);
$this -> crop($this -> src, $this -> dst, $this -> data);
}
如下所示:
function __construct($args=array())
{
if(!empty($args)){
$params = args[0];
$this->setSrc($params[0]);
$this->setData($params[1]);
$this->setFile($params[2]);
$this->crop($this->src, $this->dst, $this->data);
}
}