文件无法上传:Laravel 中缺少临时目录

问题描述

糟糕,好像出了点问题。 (1/1) 文件异常 文件无法上传:缺少临时目录。

在 UploadedFile.php(第 235 行) 在 UploadedFile->move('public/images/products/','products_8885101619419081.png') 在 ProductCtrl.php(第 54 行)

我的代码是:

      if($_FILES['attachFile']['name'] != NULL){
          $file = $request->file('attachFile');
          $photo ="products_".rand(1111,999999).strtotime('now').".".$file->getClientOriginalExtension();
          $des = "public/images/products/";
          $file->move($des,$photo);

          $mediaData['path'] = $photo;
       }

解决方法

试试这个:

  if($_FILES['attachFile']['name'] != NULL){
      $file = $request->file('attachFile');
      $photo = "products_".rand(1111,999999).strtotime('now').".".$file->getClientOriginalExtension();
      $des = "public/images/products/" . $photo;
      $file->move($des,$file);

      $mediaData['path'] = $photo;
   }

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...