You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 11+Livewire3图片上传报错:文件流打开失败

解决Laravel 11 + Livewire 3图片上传缓存目录报错问题

你遇到的报错本质是指定的缓存目录不存在或权限不足,导致Laravel无法生成缓存文件。以下是具体解决步骤:

  • 手动创建缺失的缓存目录
    直接在项目storage目录下补全路径:

    mkdir -p storage/tenantdiogo3/framework/cache
    

    Windows系统的话,打开文件管理器导航到C:\Users\Diih\Desktop\workspace2\stbox\storage,手动新建tenantdiogo3\framework\cache这几层文件夹。

  • 设置目录读写权限
    确保Web服务进程能读写该目录:

    • Linux/macOS执行:
      chmod -R 775 storage/tenantdiogo3/framework/cache
      chown -R www-data:www-data storage/tenantdiogo3/framework/cache
      
    • Windows右键目录→属性→安全,给IIS_IUSRS或当前登录用户添加读写权限。
  • 重置Laravel缓存
    运行以下命令清除旧缓存并重建:

    php artisan cache:clear
    php artisan config:clear
    php artisan view:clear
    
  • 检查多租户配置(如果用到)
    如果你用了多租户扩展,确认租户初始化逻辑里自动创建缓存目录:

    // 示例代码:在租户创建/切换时生成缓存目录
    $tenantCachePath = storage_path("tenantdiogo3/framework/cache");
    if (!File::exists($tenantCachePath)) {
        File::makeDirectory($tenantCachePath, 0775, true);
    }
    
  • 验证Livewire上传配置
    打开config/livewire.php,检查临时上传目录设置,确保livewire-tmp目录存在且有权限:

    'temporary_file_upload' => [
        'disk' => 'local',
        'directory' => 'livewire-tmp',
        // 其他配置...
    ],
    

内容的提问来源于stack exchange,提问作者Diogo Goulart

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 10:52:02