Waq*_*ary 1 php laravel laravel-5.4 laravel-5.5
我正在上传需要通过office365 API附加到电子邮件的文件。
我需要的是变量的文件内容而不存储/保存文件,我该怎么办?
foreach ($request->filesToUpload as $file) {
$originalName = $file->getClientOriginalName();//working
$content = $file->getContent();//<- I need this, but not working
//$this->addAttachment($content, $originalName) //logic for later
}
Run Code Online (Sandbox Code Playgroud)
像这样访问文件的内容:
$content = file_get_contents(Input::file('nameAttribute')->getRealPath());
Run Code Online (Sandbox Code Playgroud)
或换句话说,在那个循环内
$contents = file_get_contents($file->getRealPath());
Run Code Online (Sandbox Code Playgroud)
使用对象方法获取真实路径,您可以像其他任何文件一样与它进行交互。
| 归档时间: |
|
| 查看次数: |
2090 次 |
| 最近记录: |