【发布时间】:2014-05-16 09:38:13
【问题描述】:
我创建了一个应该上传图片的论坛。
以我的形式,我已经
{{ Form::file('image') }}
这是我的控制器的一部分:
public function store()
{
$input = Input::all();
$v = Validator::make($input, Post::$rules);
if ($v->passes()) {
$post = new Post;
$post->title = Input::get('title');
$post->body = Input::get('body');
$post->image = Input::file('image'); // your file upload input field in the form should be named 'file'
$destinationPath = 'uploads/'.str_random(8);
$filename = $post->image->getClientOriginalName();
$extension =$post->image->getClientOriginalExtension(); //if you need extension of the file
$uploadSuccess = Input::file('image')->move($destinationPath, $filename);
$post->m_keyw = Input::get('m_keyw');
$post->m_desc = Input::get('m_desc');
$post->slug = Str::slug(Input::get('title'));
$post->user_id = Auth::user()->id;
$post->save();
return Redirect::route('posts.index');
}
return Redirect::back()->withErrors($v);
}
但是 laravel 将图像作为 .tmp 文件存储在我的数据库中。
我的数据库中的路径是“/uploads/xxxxx.tmp”
为什么 laravel 将图片存储为 .tmp 而不是 .img ?
我做错了什么,为什么 laravel 将图像存储为 .tmp 文件?
【问题讨论】:
标签: php mysql laravel frameworks