$ file-> isValid()在Laravel 4.2中返回false

时间:2018-12-31 12:00:10

标签: php laravel file-upload laravel-4.2

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。

1 个答案:

答案 0 :(得分:1)

打开php.ini文件。在php.ini文件中找到这些行,并将其替换为数字

upload_max_filesize = 64M

保存更改并刷新您的网站,然后尝试再次上传文件。


检索上传的文件

$file = Input::file('photo');

确定上传的文件是否有效

if (Input::file('photo')->isValid())
{
    //
}