Could not move the file报错,该怎么解决

Taotao

#### 问题描述

Webman\Exception\FileException: Could not move the file报错,该怎么解决

程序代码

        $file = $request->file('videoToUpload');
        #打印文件信息
        if(!$file){
            echo "没有选择任何文件进行上传。";
            return view('index/index', ['name' => "请选择音视频"]);
        }

        $types = ['mp4', 'avi', 'wmv', 'rmvb', 'rm', 'mpeg', 'flv', 'mov']; //允许的扩展名
        $ext =$file->getUploadExtension();
        if (!in_array($ext, $types)) {
            echo "不支持的文件格式。";
            return view('index/index', ['name' => "不支持的文件格式"]);
        }
        $file_path = public_path() . DIRECTORY_SEPARATOR . 'video/';
        #讲接收到的文件存到public目录下的video目录里
        if(!file_exists($file_path)){
            mkdir($file_path, 0777);
        }
        if(!is_writable($file_path)){
            chmod($file_path, 0777);
        }
        $file->move($file_path);

报错信息

Webman\Exception\FileException: Could not move the file "C:\Users\白起\AppData\Local\Temp\wor1B72.tmp" to "D:\WWW\webman_video_process\public\video/" (rename(C:\Users\白起\AppData\Local\Temp\wor1B72.tmp,D:\WWW\webman_video_process\public\video/): 拒绝访问。 (code: 5)) in D:\WWW\webman_video_process\vendor\workerman\webman-framework\src\File.php:49
Stack trace:
#0 D:\WWW\webman_video_process\app\controller\IndexController.php(43): Webman\File->move('D:\\WWW\\webman_v...')
#1 D:\WWW\webman_video_process\vendor\workerman\webman-framework\src\App.php(319): app\controller\IndexController->index(Object(support\Request))
#2 D:\WWW\webman_video_process\vendor\workerman\webman-framework\src\App.php(141): Webman\App::Webman\{closure}(Object(support\Request))
#3 D:\WWW\webman_video_process\vendor\workerman\workerman\Connection\TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#4 D:\WWW\webman_video_process\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #107)
#5 D:\WWW\webman_video_process\vendor\workerman\workerman\Worker.php(1485): Workerman\Events\Select->loop()
#6 D:\WWW\webman_video_process\vendor\workerman\workerman\Worker.php(1402): Workerman\Worker::forkWorkersForWindows()
#7 D:\WWW\webman_video_process\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#8 D:\WWW\webman_video_process\vendor\workerman\webman-framework\src\support\App.php(131): Workerman\Worker::runAll()
#9 D:\WWW\webman_video_process\start.php(4): support\App::run()
#10 {main}

截图报错信息里报错文件相关代码

截图

操作系统及workerman/webman等框架组件具体版本

webman最新版本

526 1 0
1个回答

damao

按照文档,move()里的参数必须是全路径,带具体的文件名

×
🔝