2014-12-27 112 views
1

林有問題要上傳的照片和任何形式的對我的應用程序文件,因爲做上傳但作爲.tmp文件和他們沒有對我的看法正確顯示Laravel 4:移動文件上傳一次

1.-我的形式,我試着給會員上傳與名稱,組,電子郵件,描述和照片

{{Form::open(array('action' => '[email protected]','files'=>true)) }} 
    {{ Form::label('file','Agregar Imagen',array('id'=>'','class'=>'')) }} 
    {{ Form::file('file','',array('id'=>'','class'=>'')) }} 
    <br/> 
    {{Form::text('name','',array('class' => 'form-control','placeholder'=> 'Nombre'))}} 
    {{Form::text('group','',array('class' => 'form-control','placeholder'=> 'Cargo'))}} 
    {{Form::text('email','',array('class' => 'form-control','placeholder'=> 'Correo'))}} 
    {{Form::textarea('description','',array('class' => 'form-control','placeholder'=>''))}} 
    <!-- submit buttons --> 
    {{ Form::submit('Guardar') }}   
    <!-- reset buttons --> 
    {{ Form::reset('Reset') }}   
    {{ Form::close() }} 
控制器

public function addMember() 
{ 
    $name = Input::file('file')->getClientOriginalName(); 
    $newname = Input::file('file')->getFilename();  
    Input::file('file')->move(storage_path(),$name); 
    $subpath = storage_path(); 
    $path = $subpath.'/'.$newname2; 
    $name2 = Input::get('name'); 
    $email = Input::get('email'); 
    $description = Input::get('description'); 
    $group = Input::get('group'); 

    DB::table('contactgroups')->insert(
     array('group' => $group, 'name' => $name2, 'path' => $path, 'email' => $email, 'description' => $description) 
    ); 
    $members = DB::table('contactgroups')->get(); 
    return View::make('admin.members',['members' => $members]); 
} 

我知道我應該使用一個

2,我的上傳功能模型升起在我的數據庫負載的東西,但是這不是問題,現在

3 .-我顯示視圖

@extends('layouts.main') 
@section('content') 
    @foreach($members as $member) 
     <div class = "row fondue"> 
       <h3><div class="col-md-12"><b><?=$member->name ?></b></div></h3>  
       <div class="col-md-4"> <img src="<?=$member->path ?>" alt="Image" class = "contact-img"></div> 
       <div class="col-md-4"><?=$member->description ?></div> 
       <div class="col-md-4"><?=$member->email ?></div> 

     </div> 

    @endforeach 

@stop 

,這一切......的信息保存在數據庫中,但圖像無法正確顯示上視圖和文件上傳的tmp文件,我不知道爲什麼

+0

「存儲」目錄不是(或不應該)公開訪問。你將不得不將圖像存儲在'公共' – lukasgeiter 2014-12-27 14:50:04

+0

某處,但我有一些私人文件,我不想公開 – 2014-12-27 14:57:32

+0

你的意思是隻有登錄的用戶應該能夠訪問它? – lukasgeiter 2014-12-27 14:58:39

回答