public class AppDbContext : DbContext
{
public AppDbContext (DbContextOptions<AppDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Customer>(entity=>
{
entity.HasOne(customer=>customer.Course)
.WithOne(course=> course.Customer)
.HasForeignKey<Course>(course=>course.Id);
});
}
public DbSet<App.Models.Customer> Customer { get; set; }
public DbSet<App.Models.Course> Courses{ get; set; }
}
CREATE TABLE [Customer] (
[Id] int NOT NULL IDENTITY,
[Name] nvarchar(max) NULL,
CONSTRAINT [PK_Customer] PRIMARY KEY ([Id])
);
GO
CREATE TABLE [Courses] (
[Id] int NOT NULL,
[CouseName] nvarchar(max) NULL,
CONSTRAINT [PK_Courses] PRIMARY KEY ([Id]),
CONSTRAINT [FK_Courses_Customer_Id] FOREIGN KEY ([Id]) REFERENCES [Customer] ([Id]) ON DELETE CASCADE
);
GO
设置为表单。
$file = Input::file('video');
dd($file,$file->isValid());
也有所增加, apache重新启动
enctype="multipart/form-data"
有文件,但是max_upload_limit
总是返回false。
答案 0 :(得分:1)
打开php.ini
文件。在php.ini文件中找到这些行,并将其替换为数字
upload_max_filesize = 64M
保存更改并刷新您的网站,然后尝试再次上传文件。
检索上传的文件
$file = Input::file('photo');
确定上传的文件是否有效
if (Input::file('photo')->isValid())
{
//
}