Symfony2:会话上传进度

时间:2015-03-26 15:55:19

标签: php symfony session upload

我正在尝试使用symfony2的php upload_progress功能。我在php.ini中设置了session.upload_progress.prefix和session.upload_progress.name。 我的表格如下:

<form id="form-import-file" action="" method="post" {{    form_enctype(form) }} class="form-horizontal">                                    
    {{ form_widget(form.file, { 'attr':{'class':'input-file-import'}}) }}
    {{ form_rest(form) }}     
    {{ form_errors(form.file) }}
    <input type="hidden" name="{{ upload_progress_name }}" value="123" />
    <button type="submit" class="btn btn-success">Submit</button>
</form>

其中upload_progress_name = ini_get(“session.upload_progress.name”)。

上传没问题,但会话没有显示任何上传信息。 有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

Ensure that <input type="hidden" name="{{ upload_progress_name }}" value="123" /> is before the file input fields. Just place it under the form tag. Also what helped me out is this list: issues on php upload progress

Finally there is good symfony2-bundle, which may help you to not reinvent everything new.OneUpBundle With this bundle you can pick a Frontend solution or create your own one.