Laravel 5.3 Amazon s3 上传问题

Laravel 5.3 Amazon s3 upload issue

所以我最近一直在做一个项目,但我在尝试将文件上传到 s3 时遇到了困难,我以前在以前的网站上做过这个,一切都很好,但这个似乎证明了有点棘手。

我正在尝试上传通过表单发送到我在 s3 上的 'horsebeach' 存储桶的文件 (pdf),在单击表单上的提交后,页面就冻结了。

这是我的上传代码:

 $file = $request->file('attachment');
 $s3 = Storage::disk('s3');
 $s3->put($file->hashName(), file_get_contents($file));

在我的 EventController 中:

public function newEvent(Request $request){
      // in here
}

更改为本地存储工作正常,文件存储在我的应用程序存储中。

这是我的表格,有帮助:

<form action="{{URL::to('events/new')}}" method="post" enctype="multipart/form-data">
    {{ csrf_field() }}
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">Event Title:</label>
            </div>
            <div class="span10">
                <input type="text" name="event-title" placeholder="Event Title" class="span11"/>
            </div>
        </div>
    </div>
    @if ($errors->has('event-title'))
    <span class="help-block">
        <strong>{{ $errors->first('event-title') }}</strong>
    </span>
    @endif
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">Begin Date:</label>
            </div>
            <div class="span2">
                <input type="text" name="begin-date" placeholder="e.g 27-02-2016" class="span11 dpicker">
            </div>
        </div>
    </div>
    @if ($errors->has('begin-date'))
    <span class="help-block">
        <strong>{{ $errors->first('begin-date') }}</strong>
    </span>
    @endif
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">End Date:</label>
            </div>
            <div class="span2">
                <input type="text" name="end-date" placeholder="e.g 27-02-2016" class="span11 dpicker">
            </div>
        </div>
    </div>
    @if ($errors->has('end-date'))
    <span class="help-block">
        <strong>{{ $errors->first('end-date') }}</strong>
    </span>
    @endif
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">Location:</label>
            </div>
            <div class="span10">
                <input type="text" name="location" placeholder="e.g Dave's house" class="span11"/>
            </div>
        </div>
    </div>
    @if ($errors->has('location'))
    <span class="help-block">
        <strong>{{ $errors->first('location') }}</strong>
    </span>
    @endif
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">Fee:</label>
            </div>
            <div class="span10">
                <div class="input-prepend">
                    <span class="add-on">£ </span> <input type="text" id='fee' name="fee" placeholder="2000" style="width: 87%">
                </div>
            </div>
        </div>
    </div>
    @if ($errors->has('fee'))
    <span class="help-block">
        <strong>{{ $errors->first('fee') }}</strong>
    </span>
    @endif
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">Colour:</label>
            </div>
            <div class="span10">
                <div class="input-prepend">
                    <input type="text" name="colour" placeholder="" id="color1" class="color1">
                </div>
            </div>
        </div>
    </div>
    @if ($errors->has('colour'))
    <span class="help-block">
        <strong>{{ $errors->first('colour') }}</strong>
    </span>
    @endif
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">Description:</label>
            </div>
            <div class="span10">
                <textarea rows="3" name="description" placeholder="What's going down?" class="span11 elastic"></textarea>
            </div>
        </div>
    </div>
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">Confirmed?</label>
            </div>
            <div class="span10">
                <input type="checkbox" name="confirmed" class="radio1">
            </div>
        </div>
    </div>
    <div class="form_inputs clearfix">
        <div class="row-fluid">
            <div class="span2">
                <label class="control-label">Attachments:</label>
            </div>
            <div class="span10">
                <input id="fileupload" type="file" name="attachment"/>
            </div>
        </div>
    </div>
    <div class="form_inputs">
        <input type="submit" name="create-event" value="Create Event" class="btn btn-info"/>
    </div>
</form>

配置文件:

    's3' => [
        'driver' => 's3',
        'key'    => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'region' => env('AWS_LOCATION'),
        'bucket' => 'horsebeach',
    ],

composer.json:

"league/flysystem-aws-s3-v3": "~1.0"

你确定拉进来了吗aws/aws-sdk-php-laravel

我的项目中安装了以下内容:

    "aws/aws-sdk-php-laravel": "^3.1",
    "graham-campbell/flysystem": "^3.0",
    "league/flysystem-aws-s3-v3":"~1.0",

另外,跟踪你的 storage/logs/laravel.log 看看发生了什么。