我有2个文本字段和1个文件上传都是必需的.当我只需要文本字段时,一切都有效,但是当我需要文件上传时,验证错误仍然表示需要一个文件,即使我选择了一个文件.谁知道我做错了什么?提前谢谢了.
//视图
<?php echo form_open_multipart('add'); ?>
<fieldset>
<input type="text" name="name" /><br>
<input type="text" name="code" /><br>
<input type="file" name="userfile" /><br><br>
<input type="submit"value="Add" />
</fieldset>
<?php echo form_close(); ?>
Run Code Online (Sandbox Code Playgroud)
//控制器
public function add() {
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('code', 'Code', 'required');
//$this->form_validation->set_rules('userfile', 'Document', 'required');
//when the above line is active the upload does not go through
if ($this->form_validation->run() == FALSE) {
$data['page_view'] = $this->page_view;
$data['page_title'] = $this->page_title;
$this->load->view('template', $data);
}
else
{
$this->load->library('upload');
if (!empty($_FILES['userfile']['name']))
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->upload->initialize($config); …Run Code Online (Sandbox Code Playgroud) 我有以下Active Record查询.
//Example 1
public function info($school, $class, $student, $keyword)
{
$this->db->where('school.id', $school);
$this->db->where('class.id', $class);
$this->db->where('student.id', $student);
$this->db->or_where('school.description', $keyword);
$this->db->or_where('class.description', $keyword);
$this->db->or_where('student.description', $keyword);
return $this->db->get('info')->result();
}
Run Code Online (Sandbox Code Playgroud)
我想对底部3"or_where"语句进行分组,以便它们包含在前3个"where"语句中.我想出的解决方案是......
//Example 2
public function info($school, $class, $student, $keyword)
{
$this->db->where('school.description', $keyword);
$this->db->where('school.id', $school);
$this->db->where('class.id', $class);
$this->db->where('student.id', $student);
$this->db->or_where('class.description', $keyword);
$this->db->where('school.id', $school);
$this->db->where('class.id', $class);
$this->db->where('student.id', $student);
$this->db->or_where('student.description', $keyword);
$this->db->where('school.id', $school);
$this->db->where('class.id', $class);
$this->db->where('student.id', $student);
return $this->db->get('info')->result();
}
Run Code Online (Sandbox Code Playgroud)
这工作正常,但有没有办法在不重复代码的情况下执行此操作?
我正在使用Laravel 5.0,并尝试使用Dropbox进行授权。我大致遵循以下示例:http : //dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/class-Dropbox.WebAuth.html
当我去/开始。我被重定向到Dropbox并单击“允许”,但是当我被重定向回/ finish时,我在会话中不断收到Missing CSRF令牌。有人有什么想法吗?我读过这$_SESSION在Laravel中不起作用,但是我不确定该怎么做。
这是我正在使用的代码:
public function start()
{
$authorizeUrl = $this->getWebAuth()->start();
return redirect()->away($authorizeUrl);
}
public function finish()
{
$test = $this->getWebAuth()->finish($_GET);
dd($test);
}
private function getWebAuth()
{
$appKey = 'key';
$appSecret = 'secret';
$appName = 'name';
$appRedirect = 'http://example.com/finish';
$appInfo = new Dropbox\AppInfo($appKey, $appSecret);
$csrfTokenStore = new Dropbox\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
$webAuth = new Dropbox\WebAuth($appInfo, $appName, $appRedirect, $csrfTokenStore);
return $webAuth;
}
Run Code Online (Sandbox Code Playgroud)
更新1:
好的,所以我尝试与Laravel Socialite和Dropbox Socialite提供程序一起使用。我将代码更改为以下代码,但按/ start时出现错误。Driver [dropbox] not supported。我对说明的 …
我正在使用CodeIgniter和Twitter Bootstrap创建一个Web应用程序.我在网上找到了一个资源,其中包含$ config设置列表,可以正确设置分页链接的样式.有没有办法将它存储在库中并将其加载到控制器中,所以我不必每次都输入它?
我正在使用moment.js"timeAgo"来显示一些日期.但是如果日期在上周内,我只想使用moment.js.(7天前)在那之后我只想正常显示日期.例如:(2010年6月20日)而不是(3年前).
我有使用此代码的默认值.任何帮助都会很棒.
var date = moment.unix(<?php echo $date; ?>).fromNow();
$("#date").append(date);
Run Code Online (Sandbox Code Playgroud) 我在数据库中有一个列,其日期存储为mm/dd/yyyy.我需要获取日期大于某个日期的所有行.(例如,2013年1月1日之后的任何日期).如何使用活动记录执行此操作?
我试过了
$this->db->select('DATE_FORMAT(date, '%mm/%dd/%Y') as mydate');
$this->db->where('mydate >','01/01/2013');
Run Code Online (Sandbox Code Playgroud) 我的根目录中有3个文件夹,"应用程序","系统"和"上传".在application/controllers/mycontroller.php中,我有这行代码.
delete_files("../../uploads/$file_name");
Run Code Online (Sandbox Code Playgroud)
该文件没有被删除,我尝试了一些路径选项,如../和../../../任何想法?谢谢.
打印时有没有办法只使用print.css而不是styles.css?我觉得90%的print.css正在撤消styles.css中的样式.