我注意到get_mime()现在已经折旧,那么创建以下函数的替代方法是什么?此功能通过我使用的cms使用,因此需要一个可靠的替代方案.
// Mime Type Checker
function get_mime ($filename,$mode=0) {
// mode 0 = full check
// mode 1 = extension check only
$mime_types = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => …Run Code Online (Sandbox Code Playgroud) 我正在尝试上传图片并调整它们的大小,到目前为止上传工作还有拇指指甲图像的创建.但我不能让原始图像调整大小.所有发生的事情是文件以原始大小直接上传到文件夹.我想我正在尝试将此图像调整大小然后覆盖最初上传的文件.
这是我的代码,我错过了什么:
//Initialise the upload file class
$config['upload_path'] = './image_uploads/';
$config['allowed_types'] = 'jpg|jpeg|gif|png';
$config['max_size'] = '6048';
$this->load->library('upload', $config);
$userfile = "_upload_image";
//check if a file is being uploaded
if(strlen($_FILES["_upload_image"]["name"])>0){
if ( !$this->upload->do_upload($userfile))//Check if upload is unsuccessful
{
$upload_errors = $this->upload->display_errors('', '');
$this->session->set_flashdata('errors', 'Error: '.$upload_errors);
redirect('admin/view_food/'.$food->course_id);
}
else
{
//$image_data = $this->upload->data();
////[ THUMB IMAGE ]
$config2['image_library'] = 'gd2';
$config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config2['new_image'] = './image_uploads/thumbs';
$config2['maintain_ratio'] = TRUE;
$config2['create_thumb'] = TRUE;
$config2['thumb_marker'] = '_thumb';
$config2['width'] = 75;
$config2['height'] = 50;
$this->load->library('image_lib',$config2); …Run Code Online (Sandbox Code Playgroud) 我在这里使用这个jquery splitter插件:http://methvin.com/splitter/
它正在使用我正在使用的jquery版本,直到我启用resizeToWidth属性然后它给我错误:太多的递归.
这是我在jsfiddle上创建的演示的链接:http://jsfiddle.net/S97rv/4/
我看了插件代码,但我不是一个JavaScript专家,不想搞砸它.
任何人都可以看到这个错误的解决方案吗?
这是插件代码,但可能只是看看jsfiddle链接:
;(function($){
$.fn.splitter = function(args){
args = args || {};
return this.each(function() {
var zombie; // left-behind splitbar for outline resizes
function startSplitMouse(evt) {
if ( opts.outline )
zombie = zombie || bar.clone(false).insertAfter(A);
panes.css("-webkit-user-select", "none"); // Safari selects A/B text on a move
bar.addClass(opts.activeClass);
A._posSplit = A[0][opts.pxSplit] - evt[opts.eventPos];
$(document)
.bind("mousemove", doSplitMouse)
.bind("mouseup", endSplitMouse);
}
function doSplitMouse(evt) {
var newPos = A._posSplit+evt[opts.eventPos];
if ( opts.outline ) {
newPos …Run Code Online (Sandbox Code Playgroud) 如何使用laravel 5.2记录失败的登录尝试我已安装了auth脚手架.
我已将以下内容添加到EventsServiceProvider.php中
protected $listen = [
'Illuminate\Auth\Events\Attempting' => [
'App\Listeners\LogAuthenticationAttempt',
],
'Illuminate\Auth\Events\Login' => [
'App\Listeners\LogSuccessfulLogin',
],
'Illuminate\Auth\Events\Logout' => [
'App\Listeners\LogSuccessfulLogout',
],
'Illuminate\Auth\Events\Lockout' => [
'App\Listeners\LogLockout',
],
];
Run Code Online (Sandbox Code Playgroud)
在我的app/Listeners/LogAuthenticationAttempt.php中
我有
$log = new Access_Log();
$log->ip_address = Request::getClientIp();
$log->is_success = 0;
$log->save();
Run Code Online (Sandbox Code Playgroud)
但这只是记录已经进行了登录尝试>我可以使用LogSuccessfulLogin侦听器记录成功登录尝试但我无法查看如何记录失败的登录尝试.
在我看来,我可以只更新LogSuccessfulLogin Listener中日志条目的is_success值,但是我可以使用什么来保持LogAuthenticationAttempt和LogSuccessfulLogin之间的相同登录尝试?
以下活动记录WHERE IN查询不起作用。根据文档,这应该工作:
$data = $dropDownData->find()
->select('country, country_text')
->distinct()
->WHERE(['in', 'server', $servers]);
$listData = ArrayHelper::map($data,'country', 'country_text');
Run Code Online (Sandbox Code Playgroud)
sql等效项是:
$query = "SELECT DISTINCT country, country_text
FROM `dropDownData`
WHERE server IN ({$servers})";
Run Code Online (Sandbox Code Playgroud)
$ servers仅包含字符串1,2,4
我在这里做错了什么?
我究竟如何检查第一个字符$value是£,然后删除它,如果是?
更好的方法是检查它是否不是数字,然后将其删除.
我目前的代码:
echo '<dl style="margin-bottom: 1em;">';
foreach ($row as $key => $value)
{
echo "<dt>$key</dt><dd>$value</dd>";
}
echo '</dl>';
Run Code Online (Sandbox Code Playgroud) 好的,我有两个表 Clients 和 Quotes 两个表都有一个 EnqNo 列。客户有两个空列“项目”、“报价”。报价有两列“项目”和“估计”。我需要用项目更新客户,并从 EnqNo 匹配的报价中估计字段。因此,客户中的报价从每一行的报价中获取估计值。合理?
我正在努力让查询工作:
update Clients
set Clients.Project = Quotes.Project
from Clients, Quotes
where Quotes.EnqNo = Clients.EnqNo
Run Code Online (Sandbox Code Playgroud) 我有一个for each循环,它通过一组线循环,每条线都有一个安装日期,但是我只想从所有循环中获得最早的安装日期,这可以是循环中的任何随机线。我该怎么办?我应该只创建一个日期数组然后对其进行排序还是应该在每次循环时检查一下?一个代码示例将是最好的。日期的格式很简单:2012-09-04
foreach($lines as $line){
$install_date = $line->installation_date_c;
$water_cost = $line->water_cost_c;
$energy_cost = $line->energy_cost_c;
$oweeks = 52;
$oyears = $line->operating_years_c;
$default_curr = $line->currency_id;
}
Run Code Online (Sandbox Code Playgroud) 你好,我是 Laravel 新人,在理解如何创建关系方面有点挣扎。我正在尝试在 laravel 中制作一个基本的 Restful api 并有 3 个模型
class Book extends Model {
public function author()
{
return $this->belongsTo(Author::class);
}
public function categories()
{
return $this->belongsToMany('App\Category', 'category_book')
->withTimestamps();
}
}
class Author extends Model
{
public function books(){
return $this->hasMany(Book::class);
}
}
class Category extends Model
{
public function books()
{
return $this->belongsToMany('App\Book', 'category_book')
->withTimestamps();
}
}
Run Code Online (Sandbox Code Playgroud)
表迁移:
Schema::create('books', function (Blueprint $table) {
$table->engine = "InnoDB";
$table->increments('id');
$table->string('ISBN', 32);
$table->string('title');
$table->integer('author_id')->unsigned();
$table->float('price')->default(0);
$table->timestamps();
});
Schema::create('authors', function (Blueprint $table) …Run Code Online (Sandbox Code Playgroud) 如何使用jquery查找当前所选选项的位置,如果用户选择其他选项,还需要实时更新.
<select id="visa_type_c" title="" name="visa_type_c">
<option selected="selected" value="No Visa" label="No Visa">No Visa</option>
<option value="EU Visa" label="EU Visa">EU Visa</option>
<option value="Easy Visa" label="Easy Visa">Easy Visa</option>
<option value="Hard Visa" label="Hard Visa">Hard Visa</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我看到了其他线程,但它们略有不同,我似乎无法让它适合我.
使用以下谷歌图表,我将如何通过单击图例来隐藏一条线?它目前有两条线 Elec 和 Gas 我希望能够根据单击相应的图例来隐藏或显示每一行。我知道我必须向图表添加一个事件侦听器函数,但我有点不知道如何在这个特定的图表上做到这一点。我能找到的例子略有不同。
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Time', 'Electricity', 'Gas'],
[new Date('2017-05-01'), 12.903, 4.624],
[new Date('2017-05-02'), 15.82, 34.4],
[new Date('2017-05-03'), 9.087, 29.542],
[new Date('2017-05-04'), 11.094, 18.003],
[new Date('2017-05-05'), 10.709, 16.573],
[new Date('2017-05-06'), 10.547, 67.86],
[new Date('2017-05-07'), 22.491, 4.011],
[new Date('2017-05-08'), 14.245, 14.898],
[new Date('2017-05-09'), 0, 0],
[new Date('2017-05-10'), 0, 0],
[new Date('2017-05-11'), 0, 0],
[new Date('2017-05-12'), 0, 0],
[new Date('2017-05-13'), 0, 0],
[new Date('2017-05-14'), 0, 0],
[new Date('2017-05-15'), 0, 0],
[new Date('2017-05-16'), 0, 0], …Run Code Online (Sandbox Code Playgroud) php ×7
javascript ×3
jquery ×3
laravel ×2
laravel-5 ×2
arrays ×1
charts ×1
codeigniter ×1
datetime ×1
eloquent ×1
laravel-5.2 ×1
mysql ×1
sql ×1
yii2 ×1