【发布时间】:2018-02-12 10:45:46
【问题描述】:
我从带有composer的packagist下载了一个包到我的laravel项目,这个包只是为了在我提供视频文件时获取电影字幕,但每次我上传电影文件时它都会验证错误,我不知道为什么,这是 php/laravel 代码
public function store(Request $request)
{
$file = $request->movie;
// dd($request);
// $file = 'E:/Media/Jack reacher.mp4';
if (empty($file)) {
echo 'error! you must supply a file';
return 1;
}
if (!is_file($file)) {
echo 'error! file ' . $file . ' does not exist';
return 2;
}
$config = Yaml::parse(file_get_contents(__DIR__ . '/config/configuration.yml.dist'));
if (empty($config)) {
echo 'error! config file does not exist';
return 3;
}
$manager = new SubtitlesManager($config['username'], $config['password'], $config['language']);
$subtitles = $manager->get($file);
if (!empty($subtitles) && !empty($subtitles[0])) {
$fileGenerator = new FileGenerator();
$fileGenerator->downloadSubtitle($subtitles[0], $file);
} else {
echo 'error! impossible to find the subtitle';
}
}
它总是返回一个错误说
错误!文件 jackreacher.mp4 不存在2
此特定条件一直返回错误
if (!is_file($file)) {
echo 'error! file ' . $file . ' does not exist';
return 2;
}
【问题讨论】:
-
您能提供表格代码吗?
-
啊,这很尴尬,我刚看到错误。我没有在表单中添加 enctype="multipart/form-data" 属性
-
是的,我正要这么说,这就是我问的原因
标签: php laravel file filesystems package