当尝试将图像上传到 laravel 存储时,出现错误。
SplFileInfo::getSize(): C:\xampp\tmp\php3624.tmp 统计失败
但我什至没有使用 SplFileInfo 函数。这是我的代码。
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required|max:191',
'sub_title' => 'required|max:191',
'description' => 'required',
'active' => 'required',
'img' => 'image|mimes:jpg,png,svg,gif,jpeg|max:2048'
]);
$services = new Services;
if($request->hasFile('img')){
$imageName = time().'_NEWS.'.$request->file('img')->getClientOriginalExtension();
// dd($request->file('img')->getMaxFilesize());
$services->news_image = $imageName;
$request->file('img')->move(public_path('storage/services/'), $imageName);
}
$services->title = $request->input('title');
$services->sub_title = $request->input('sub_title');
$services->description = $request->input('description');
$services->active = $request->input('ative');
$services->save();
return redirect('/admin/services')->with('success', 'Succesvol een behandeling aangemaakt');
}
Run Code Online (Sandbox Code Playgroud)
我希望有人能在这里帮助我。我已经知道它是 Symfony 错误,但我找不到任何问题的答案。我已经改变了我的
post_max_size=40M 和 upload_max_filesize=40M
在 PHP.ini 中,所以这不会成为问题。
这是我尝试过的
中间件
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Credentials', 'true')
->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Authorization, X-Requested-With, Accept, X-Token-Auth, Application')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
Run Code Online (Sandbox Code Playgroud)
API路线
Route::group(['middleware' => ['cors', 'auth:api']], function() {
Route::options('{any}');
Route::post('user/profile','UserController@profile');
Run Code Online (Sandbox Code Playgroud)
内核.php
protected $routeMiddleware = [
'cors' => \App\Http\Middleware\Cors::class,
Run Code Online (Sandbox Code Playgroud)
但是,我仍然在来自另一个来源的 API 调用中收到此错误。
对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。
任何原因?
我知道这个
{{route('editApplication', ['id' => $application->id])}} == /application/edit/{id}
Run Code Online (Sandbox Code Playgroud)
但是我需要
?? == /application/edit?appId=id
Run Code Online (Sandbox Code Playgroud)
任何人,请替换“??” 你的回答对我有帮助。
具有以下输入的图像用于表单请求验证。
[
'relations' =>
[
[
'primary' => true,
],
[
'primary' => false,
],
],
],
Run Code Online (Sandbox Code Playgroud)
是否有任何验证可以确保至少一个关系模型的主要设置为 true?如果能确保只有一个元素为真就更完美了。这个问题似乎以前就存在过。
因此,如果我们只看到关系的输入,这应该会通过。
[
'primary' => true,
],
[
'primary' => false,
],
Run Code Online (Sandbox Code Playgroud)
这应该在验证中失败。
[
'primary' => false,
],
[
'primary' => false,
],
Run Code Online (Sandbox Code Playgroud) 我在这个文件中遇到了这个错误:route/api.php 这个错误指的是第 16 行
<?php
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
16- Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request::user();
});
Route::post('login', 'Api\AuthController@login');
Run Code Online (Sandbox Code Playgroud) 正如我在问题中提到的,我正在处理的当前 Laravel 6.0 项目有一些奇怪的数据库设置,其中模型(此处的 MainModel)MySQL 表已设置为AutoIncrementas NULL。并且客户端根本不允许更改表的定义。
我想在插入记录之前可靠地找到模型的下一个和上一个 ID(因为我无法从表中找到,因为 AutoIncrement 设置为 NULL),以便我可以输入相关记录(例如图像) )首先将主模型的 ID 正确插入到另一个表的参考 ID 字段中,将推荐/常见问题解答或任何所见即所得内容字段)插入到另一个参考表中。
目前我的主模型中有这个,但该next方法不能可靠地一致地返回精确的递增 ID:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Te7aHoudini\LaravelTrix\Traits\HasTrixRichText;
class [MainModel] extends Model
{
use HasTrixRichText;
protected $guarded = [];
public $timestamps = false;
protected $primaryKey = 'id';
protected $connection = '[connection1]';
protected $table = '[main_table]';
protected $fillable = ['id', '[titlefield]', '[wysiwyg_field]'];
/**
* Setup model event hooks
*/
public static function boot()
{
parent::boot();
self::creating(function ($model) { …Run Code Online (Sandbox Code Playgroud) ini_set在 Laravel 应用程序中运行函数(在运行时设置整个应用程序值)的最佳位置是什么?
编辑:
目标是设定bcmath.scale价值,但消除所有项目开发人员在其本地环境中接触 php.ini 的需要。
我最近正在为数据库中的简单 2 条记录生成报告。为了生成此报告,我使用 Laravel dompdf 包,但下载时间太长,这是意料之外的。我使用的代码如下:
$pdf = PDF::loadView('dashboard.sales-report', compact('sales'));
$pdf->setPaper('A4', 'portrait');
$sales_report_file_name = "daily_sales_".date('Y-m-d').".pdf";
return $pdf->download($sales_report_file_name);
Run Code Online (Sandbox Code Playgroud)
并在我们的视图页面中使用 css。但只有两条记录时间超过2分钟。有人可以帮我吗?提前致谢。
刀片文件代码:
@extends('layouts.invoice_master')
@section('content')
@php
$total_discount = 0;
$total_advance = 0;
$total_net_sum = 0;
$total = 0;
@endphp
<!-- START CONTAINER FLUID -->
<div class=" container-fluid container-fixed-lg">
<!-- START card -->
<div class="card card-default m-t-20">
<div class="card-body">
<!-- Define header and footer blocks before your content -->
<header>
<p>{{ $report_for }} </p>
<p>{{ $report_for_date }}</p>
<p>{{ $report_for_month }}</p>
</header>
<div class="invoice padding-50 …Run Code Online (Sandbox Code Playgroud) 我想创建一个新项目,以便可以稍微进行身份验证,看看我能做什么。但是,当我尝试运行make:auth命令时,出现错误。
我决定查看composer.json文件,看看我是否拥有过时的Composer版本,但是我看到了更新的laravel / framework。
我找不到有关make:auth被删除的命令的任何信息,所以我想我会来这里询问。
Command "make:auth" is not defined.
Did you mean one of these?
make:channel
make:command
make:controller
make:event
make:exception
make:factory
make:job
make:listener
make:mail
make:middleware
make:migration
make:model
make:notification
make:observer
make:policy
make:provider
make:request
make:resource
make:rule
make:seeder
make:test
Run Code Online (Sandbox Code Playgroud) 错误:
请删除或重命名“应用”配置文件中的Redis外观别名,以避免与PHP Redis扩展名冲突

我把这段代码放在我的 cache.php
'default' => env('CACHE_DRIVER', 'redis'),
那些代码在我的控制器中:
$data['posts'] = cache('posts',function(){
Post::with('user')
->select('title', 'created_at', 'user_id', 'thumbnail_path', 'content')
->orderBy('created_at','desc')
->take(50)
->get();
});
Run Code Online (Sandbox Code Playgroud)