我与"symfony/symfony": "~3.4",
和"knplabs/gaufrette": "^0.3.0",
合作,将媒体上传到Google存储空间。但是如果使用epub
文件,当我在正文epub
请求中添加post
文件时,我的文件没有名称或路径
epubUrl = {Symfony\Component\HttpFoundation\File\UploadedFile} [7]
test = false
originalName = "RU EJTOP epub r1 (2).epub"
mimeType = "application/octet-stream"
size = 0
error = 1
*SplFileInfo*pathName = ""
*SplFileInfo*fileName = ""
和动作捕获错误
Warning: file_get_contents(): Filename cannot be empty
来自上传功能,因为file_get_contents
需要一些路径
public function upload(
UploadedFile $file,
$target,
$allowedMimeTypesArray,
$name
) {
if (!$allowedMimeTypesArray) {
$allowedMimeTypesArray = self::$allowedMimeTypes;
}
// Check if the file's mime type is in the list of allowed mime types.
if (!in_array($file->getClientMimeType(), $allowedMimeTypesArray, true)) {
throw new \InvalidArgumentException(
sprintf(
'Files of type %s are not allowed.',
$file->getClientMimeType()
)
);
}
$y = file_get_contents($file->getPathname());
$this->storeFile($target, file_get_contents($file->getPathname()), $name);
return $name;
}
private function storeFile($target, $data, $name)
{
/** @var GoogleCloudStorage $fileSystem */
$fileSystem = $this->getFileSystem($target);
if (false === $fileSystem->write($name, $data)) {
throw new \Exception('Storing file failed');
}
}
如何在谷歌存储中上传epub文件然后阅读? 以及如何在php中使用epub文件?
答案 0 :(得分:0)
我发现,php.ini
upload_max_filesize
在增加之后 - 使用路径和名称上传的文件并获取内容并写入go google storage。因为需要在UploadedFile类中跟踪错误