Laravel文件上传只是上传.tmp文件


Laravel file upload just uploads .tmp file

由于某些原因,这在我看来不起作用:

{!! Form::open(['url'=>'notes','file'=>true]) !!}

所以我只是用了这个似乎让我更进一步的东西:

{!! Form::open(['url'=>'notes','enctype'=>'multipart/form-data']) !!}

在我的PostsController的存储方法中,我有以下内容:

    $file = Input::file('picture');
    $file->move(public_path(). /pictures/');

当我尝试上传.jpeg文件时,一个.tmp文件会被上传到正确的文件夹中,但它只是一个.tpm文件,上面写着:

"该文件无法在编辑器中显示,因为它是二进制,非常大或使用和不支持的文本编码。"

不确定为什么不上传.jpeg文件本身。

你可能想试试这个

$file = Input::file('picture');
$destinationPath = public_path(). '/pictures/';
$filename = $file->getClientOriginalName();
Input::file('picture')->move($destinationPath, $filename);
        if ($request->file('photo')) {
        $destinationPath = "packages/.../img/media/";
        if (!is_dir($destinationPath)) {
            mkdir($destinationPath, 0777, true);
        }
        $final_location = $destinationPath . "/";
        $request->file('photo')
        ->move($final_location, filename.'.'. $request->file('photo')
        ->getClientOriginalExtension());
        }