当我通过表单上传一些视频时,它会将我的视频保存在公共文件夹中,但view
我无法访问它们。
我的观点(想输出文件路径)
<td>{{ $media->video_ogg}} </td>
<td>{{ $media->video_mp4}} </td>
结果
C:\Users\Jeffrey\AppData\Local\Temp\phpBB7C.tmp
C:\Users\Jeffrey\AppData\Local\Temp\phpBB7C.tmp
它应该在不同的路径(我的项目路径)上。
在我的本地计算机上的视频文件夹中,我可以看到视频已上传。
我的控制器.php
public function store(Request $request)
{
// Validation //
$validation = Validator::make($request->all(), [
'about_me' => 'required',
'video_ogg' => 'required|mimes:mp4,ogx,oga,ogv,ogg,webm|min:1|max:3240',
'video_mp4' => 'required|mimes:mp4,mov,ogg,qt,webm|min:1|max:3240'
]);
// Check if it fails //
if( $validation->fails() ){
return redirect()->back()->withInput()
->with('errors', $validation->errors() );
}
$profile = new Profile;
// upload the media //
$file = $request->file('video_ogg');
$destination_path = 'videos/';
$filename = str_random(6).'_'.$file->getClientOriginalName();
$file->move($destination_path, $filename);
// upload the media //
$file = $request->file('video_mp4');
$destination_path = 'videos/';
$filename = str_random(6).'_'.$file->getClientOriginalName();
$file->move($destination_path, $filename);
// save media data into database //
$profile->about_me = $request->input('about_me');
$profile->video_mp4 = $request->file('video_mp4');
$profile->video_ogg = $request->file('video_ogg');
$profile->save();
return redirect('/profile')->with('message','You just created your profile!');
}
文件权限(在 Windows powershell 上)
那么我怎样才能获得正确的路径view
呢?
因为它应该是:videos/QvWjJ2_mov_bbb.mp4
和videos/muWzE9_mov_bbb.ogg