2014-04-21 3 views
1

파일을 올 바릅니다. 필자의 경우, 시작 디렉토리는 Public이고, 이전 인증에 의해 보호되는 디렉토리에있을 때, 즉 App 아래에 있어야 할 때 모두가 파일을 액세스 할 수 있다는 결과가 나온다. 그래서Laravel 올바른 디렉토리에 파일 업로드

, 나는 할 때 :

파일이 여기에 저장됩니다
$file = Input::file('fichero'); 
$destinationPath = 'uploads/folder'; 
$file->move($destinationPath); 

// Create model 
$model = new Model; 
$model->filename = $file->getClientOriginalName(); 
$model->destinationPath = $destinationPath; 

: localh .../myweb/공공/

하고이 앱 상위 폴더 외부에 내 모든 응용 프로그램입니다 파일이 있습니다.

나는 그것이 localhost입니다 구성 파일의 기본을 가지고 있기 때문에 그 디렉토리로 이동하는 사실은 상상할 수/laravel/공공/index.php에/

때문에,

같은 것을 쓰기
$file->move(base_path().'/uploadfolder/subdirectory/', $newname); 

은 base_path로 고정되지만 base_path는 localhost/mywebname/public과 같아야합니다.

그래서 경로를 작성하여 공용 아래에 있지 않고 응용 프로그램 아래의 디렉토리로 이동하는 방법은 무엇입니까?

나는 바보 같은 질문을하지 않기를 바랄 뿐이지 만 나는 며칠 동안 노력해 왔으며 여기서 3 가지 관련 검색어를 읽었습니다.

답변

0

당신은 사용할 수 있습니다 감사합니다 :

app_path() // Path to the 'app' folder 
app_path('controllers/admin') // Path to the 'app/controllers/admin' folder 

이 당신에게 로컬 파일 시스템 경로를 반환합니다, 당신은 public/... 폴더에 업로드 된 이미지를 넣어해야합니다.

+0

대단히 감사합니다! 최고의 gereetings –

+0

당신은 환영합니다 @ user3469557 :-) –

관련 문제