gpt4 book ai didi

php - 如何在 Laravel 5.5 中获取变量中的文件内容

转载 作者:行者123 更新时间:2023-12-02 07:19:54 26 4
gpt4 key购买 nike

我正在上传需要通过 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
}

最佳答案

像这样访问文件的内容:

$content = file_get_contents(Input::file('nameAttribute')->getRealPath());

或者换句话说在那个循环内
$contents = file_get_contents($file->getRealPath());

使用对象方法获取真实路径,您可以像任何其他文件一样与其交互。

关于php - 如何在 Laravel 5.5 中获取变量中的文件内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49166403/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com