有没有办法遍历Laravel 4中的请求文件对象?我想做这样的事情:
foreach (Input::files() as $file) {
$filename = str_random(8) . '-' . $file->getClientOriginalName();
$uploadSuccess = $file->move($destinationPath, $filename);
// ...
}
我想使用 Input:: 方法而不是迭代 $_FILES
数组。谢谢
进入Symfony代码,你可能能够:
foreach (Request::instance()->files->all() as $file) {
$filename = str_random(8) . '-' . $file->getClientOriginalName();
$uploadSuccess = $file->move($destinationPath, $filename);
// ...
}
看看
Symfony'Component'HttpFoundation'FileBag
和
Symfony'Component'HttpFoundation'ParameterBag
为了更好地了解您可以用它们做什么。