S
S
Sergei Gurdjiyan2017-09-13 17:32:13
open server
Sergei Gurdjiyan, 2017-09-13 17:32:13

How to fix File not found at path: C:/OSPanel/userdata/temp/phpB79B.tmp error on OpenServer?

Saving a file in Laravel

public function uploadFile($file)
    {
        dump($file);
        $time = Carbon::now()->toDateTimeString();
        $fileName = str_replace(' ', '_', $time . '_' . $file->getClientOriginalName());
        $uploadPath = public_path() . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'workplacesForm';
//        $file->move($uploadPath, $fileName);
        Storage::copy($file, $uploadPath . DIRECTORY_SEPARATOR . $fileName); 
    }

and i get an error
File not found at path: C:/OSPanel/userdata/temp/phpB79B.tmp

Server - OpenServer.
File dump from method above:
UploadedFile {#272
  -test: false
  -originalName: "eee.txt"
  -mimeType: "text/plain"
  -size: 0
  -error: 0
  #hashName: null
  path: "C:\OSPanel\userdata\temp"
  filename: "phpDCEC.tmp"
  basename: "phpDCEC.tmp"
  pathname: "C:\OSPanel\userdata\temp\phpDCEC.tmp"
  extension: "tmp"
  realPath: "C:\OSPanel\userdata\temp\phpDCEC.tmp"
  aTime: 2017-09-14 05:48:21
  mTime: 2017-09-14 05:48:21
  cTime: 2017-09-14 05:48:21
  inode: 0
  size: 0
  perms: 0100666
  owner: 0
  group: 0
  type: "file"
  writable: true
  readable: true
  executable: false
  file: true
  dir: false
  link: false
  linkTarget: "C:\OSPanel\userdata\temp\phpDCEC.tmp"
}

It also turned out that after loading the file, it appears in the temp folder, for a moment and disappears, I excluded my logic for working with the file.
Why is this happening?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergei Gurdjiyan, 2017-09-14
@mrKorg

In short, it's all my own fault:

$time = Carbon::now()->toDateTimeString();
        $fileName = str_replace(' ', '_', $time . '_' . $file->getClientOriginalName());

So I generate an invalid name for the file, namely a string in which the time has a ":" separator, so I simply could not rename the file.

C
ctpayc, 2017-09-14
@ctpayc

From the documentation:
The copy method may be used to copy an existing file to a new location on the disk: I think your $file is either not saved yet or not there (C:/OSPanel/userdata/temp/phpB79B. tmp)...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question