根据服务器的不同下载文件

时间:2017-04-26 13:28:38

标签: php symfony file-upload php-ini

我将此代码与Symfony 2.8

一起使用
protected function getFiles(FileBag $bag)
{
    $files = array();
    $fileBag = $bag->all();
    dump($fileBag);
    ....
}

在我的开发环境(Ubuntu 16.04PHP 5.6Apache 2)中,$fileBag很好:

array:1 [▼
  "listing" => array:1 [▼
    "image" => array:1 [▼
      "new" => array:1 [▼
        0 => UploadedFile {#14 ▼
          -test: false
          -originalName: "logo2.gif"
          -mimeType: "image/gif"
          -size: 7719
          -error: 0
          path: "/tmp"
          filename: "phpPymk91"
          basename: "phpPymk91"
          pathname: "/tmp/phpPymk91"
          extension: ""
          realPath: "/tmp/phpPymk91"
          aTime: 2017-04-26 14:49:16
          mTime: 2017-04-26 14:49:16
          cTime: 2017-04-26 14:49:16
          inode: 278115
          size: 7719
          perms: 0100600
          owner: 33
          group: 33
          type: "file"
          writable: true
          readable: true
          executable: false
          file: true
          dir: false
          link: false
        }
      ]
    ]
  ]
]

但是在服务器中(天蓝色Ubuntu 14.04PHP 5.5)我有这样的结果:

array:1 [▼
  "listing" => array:1 [▼
    "image" => array:1 [▼
      "new" => array:1 [▼
        0 => UploadedFile {#14 ▼
          -test: false
          -originalName: "logo2.gif"
          -mimeType: "application/octet-stream"
          -size: 0
          -error: 1
          path: ""
          filename: ""
          basename: ""
          pathname: ""
          extension: ""
          realPath: "/var/www/html/web"
          aTime: 1970-01-01 01:00:00
          mTime: 1970-01-01 01:00:00
          cTime: 1970-01-01 01:00:00
          inode: false
          size: false
          perms: 00
          owner: false
          group: false
          type: false
          writable: false
          readable: false
          executable: false
          file: false
          dir: false
          link: false
        }
      ]
    ]
  ]
]

路径,大小,mimeType ......都不好。

php.ini看起来一样。

有你的想法吗?

1 个答案:

答案 0 :(得分:0)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="11"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1" android:background="@drawable/border" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="test1" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="2" android:background="@drawable/border" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="test" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="2" android:background="@drawable/border" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="test" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="2" android:background="@drawable/border" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="test" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="2" android:background="@drawable/border" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="test" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="2" android:background="@drawable/border" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="test" /> </LinearLayout> </LinearLayout>

中缺少output_buffering = On

感谢您的建议和https://stackoverflow.com/a/37595453/3351765