2015-10-07 70 views
1

我在Heroku中使用Laravel 5.1框架和Clear DB廣告將文件上傳到Heroku應用程序時出現問題。
已經閱讀Laravel文檔,但我認爲這個問題是在保存方法... 我的意思是在本地模式下正常工作:Heroku Laravel 5.1文件系統上傳

1) \Storage::disk('local')->put($name, \File::get($file)); 

or 

2) 

    $name = $request->file->getClientOriginalName(); 
    Storage::put($name, 
    file_get_contents($request->file('path')->getRealPath()) 
    ); 

I use "\Storage::disk('local')" because i supose 's3' for amazon and Rackspace Cloud Storage... shall i use disk('web') or something like that? 
any suggestion? 

回答

2

在Heroku的每一個賽道是一個獨立的容器與其他無共享。這意味着寫在磁盤上的文件不會被其他dynos使用,並且一旦應用程序重新啓動或重新部署就會丟失。

https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem

正因爲如此,你不能依賴於本地文件系統(它會破壞12factor)。您需要將它們存儲在Amazon S3等遙遠的平臺上。
請參閱https://devcenter.heroku.com/articles/s3-upload-php

+0

這就是爲什麼我試圖以不同的方式上傳,但沒有人工作,大聲笑 謝謝你! –