File not found at path when trying to copy

laravel storage file not found
laravel download file from url to storage
laravel storage copy file
laravel read uploaded file
laravel storage_path
download file laravel
laravel file exists
save file in laravel

I'm trying to copy a file from one location to another. I'm pretty sure the location is correct, but I'm still getting the error in the title.

Here's some code:

$oDirectory = new \RecursiveDirectoryIterator($extractFolder.'/res');
$oIterator = new \RecursiveIteratorIterator($oDirectory);
foreach($oIterator as $oFile) {
    if ($oFile->getFilename() == 'icon.png') {
        $icons[filesize($oFile->getPath().'/icon.png')] = $oFile->getPath().'/icon.png';
$icon_source = end($icons);
echo $icon_source;
$generated_icon_file = str_slug($packagename.$version).'.png';
Storage::copy($icon_source, $generated_icon_file);

The print_r returns (which means the files exist):

Array ( [19950] => /var/www/ [31791] => /var/www/ [6979] => /var/www/ [10954] => /var/www/ )

The echo returns:


And the exact error is:

File not found at path: var/www/

P.S. PHP's copy function works just great.

I can't find the problem here.

Any suggestions?

First of all, if you are using Laravel's Storage Facade and with that the underlying Flysystem you have to know, that it is not intended to work with absolute paths like you did. The benefit of that is, that you could potentially work with different storage disks, that all have own configurations, that can be set in your config/filesystems.php file.

Assuming you did not change anythig there, the default "disk" would be local with an root of storage_path('app') ( = the path to your laravel storage folder/app )

If you want to know, why it is failing, we have to take a look at the source code you will find in the following code in the file vendor\league\flysystem\src\Filesystem.php

public function copy($path, $newpath)
    $path = Util::normalizePath($path); // <-- this will strip leading /
    $newpath = Util::normalizePath($newpath);
    $this->assertPresent($path); // this will cause the error in your case, because assertion cannot be fullfilled in case of missing leading / 

    return $this->getAdapter()->copy($path, $newpath); // calls the copy of your Adapter, assuming local in your case

So have a look, what would go on, if $this->getAdapter()->copy($path, $newpath) was called:

File (assuming local storage disk): vendor\league\flysystem\src\Adapter\Local.php

public function copy($path, $newpath)

    $location = $this->applyPathPrefix($path);
    $destination = $this->applyPathPrefix($newpath);
    return copy($location, $destination);

The line

$location = $this->applyPathPrefix($path);

will prepend the root path as defined in config/filesystems.php

'disks' => [

    'local' => [
        'driver' => 'local',
        'root'   => storage_path('app'),

As I can see in your code your files are are not stored in storage/app, so i think you have to change this to 'root' => storage_path()

So if you want to use Storage::copy() you have just to provide paths relative to that folder. And as it is hard to see, how you could achieve this, take a look at that.

    foreach($oIterator as $oFile) {
        if ($oFile->getFilename() == 'icon.png') {
            $icons[filesize($oFile->getPath().'/icon.png')] = $oIterator->getSubPath().'/icon.png';

There is RecursiveDirectoryIterator::getSubPath (Although quite undocumentated, which would return you the current subpath of your iterations. In your case relative to $extractFolder.'/res'.

Now you have to make sure you are calling

Storage::copy($icon_source, $generated_icon_file);

Where $icon_source and $generated_icon_file are relative to your defined 'root'.

Laravel File not found at path ? · Issue #796 · thephpleague , copy works only inside of the adapter. If you need to copy a file from one adapter to another, you need to fetch the content or a stream from the  Files named in a COPY command are read or written directly by the server, not by the client application.Therefore, they must reside on or be accessible to the database server machine, not the client.

You said that the error is like this:

File not found at path: var/www/

Here error is saying it cannot find at var/www that means it's looking for whereas your file is located somewhere at /var/www. A quick fix to this can be use file protocol. Just use it like:


[BUG] 'File not found at path' when importing file on server while , When I try following the documentation on importing a file stored on the server, I get an Illuminate\Contracts\Filesystem\FileNotFoundException  Says "Item Not Found Could not find this item Verify this item's location and try again." I had this file sent to me from my friend - it's a word document I had on their computer. So I tried using Disk Cleanup to delete temporary files, temp internet files, and downloaded program files.

Try with File::copy($file, $dest) instead of Storage::copy($old, $new) File::copy() is the wrapper on PHP's copy() function

Laravel File not found at path ?, But i get error while i am trying to move my local store file into dropbox. Storage::​disk('dropbox')->copy(public_path('test.txt'), 'text.txt');. Why i get error please  Sometimes you get an error when trying to move, delete, or copy directories where the character count for the file path is more than 260. Note that the words directory and folder are interchangeable. We’ll use ‘directory’ going forward. The following PowerShell cmdlets can also be used on files.

Insert / before var/www/

The path is relative to current directory. Buy if you add /, the path is absolute from root directory.

Storage::move giving "File not found at path:" (rename file), Storage::move giving "File not found at path:" (rename file). Posted 2 years ago by omarsow94. I have somethink like : $old = URL::to('/').'/'. Ways to use PowerShell commands to copy files. To show how the various Copy-Item parameters work, create a test file with the following command: Get-Process | Out-File -FilePath c:testp1.txt. Use this command to copy a file: Copy-Item -Path C:testp1.txt -Destination C:test2

you have to choose the right disk somthing like this

$file2 ='public/'.$page->thumbnail;

$destination = 'public/bundles/ttt.png';

if( Storage::disk('local')->exists($file2)){


copy - Manual, If you try to copy a file to itself - e.g. if the target directory is just a symlink to the source throw new Exception( "Remote file not found: $fURI", $http_status[1] ); When you save your file, the original file is then deleted and the temporary file is renamed with the original file name. If this process is interrupted, your file may not be saved properly or you may find one or more temporary files in the folder where you tried to save your file.

Copying files from a mapped drive to a local directory fails with error , Copying files from a mapped drive to a local directory fails with error inserted, or that you are connected to the Internet or your network, and then try again. If it still cannot be located, the information might have been moved to  If you're trying to run a local tool, verify that there's a manifest file called dotnet-tools.json in the current directory or any of its parent directories. This file can also live under a folder named.config anywhere in the project folder hierarchy, instead of the root folder.

"Windows cannot access the specified device, path, or file" error , path, or file. You may not have the appropriate permission to access the item. "Windows cannot access the specified device, path, or file" error when you try to install, update or start a program or file This issue can occur if any of the following scenarios exist on your PC. Copy URL into your reader. Make sure that the path of the file contains no more than the maximum number of characters. To do this, use one of the following methods. Rename the file so that it has a shorter name. Rename one or more folders that contain the file so that they have shorter names. Move the file to a folder that has a shorter path name.

Backup for Files, Backup for Files - Backup fails due to path not found error The file it is trying to backup is on a network mapped drive, and the network mapped The volume shadow copy service was not able to create a snapshot of the  So i know the pdf's are good. I tried to copy the pdf's to the C drive and that did not help. There are some pdf files on my D drive that will open. So I know that Reader DC is installed correctly. It appears that my older pdf files will not open in Firefox either. But other pdf files will.