July 30, 2026 — The unofficial Laracon US Day 3. Get your ticket to The Vibes

You're viewing pre-release documentation — version 4.x is in beta

Features, APIs and behaviour may change before the stable release. View the stable version (3.x)

File


Overview#

The File API performs native file operations — moving and copying files — using each platform's file system directly.

It's a core built-in: the facade resolves with nothing to install or register.

Copied!
use Native\Mobile\Facades\File;

Move#

Copied!
$ok = File::move('/path/to/source.txt', '/path/to/destination.txt'); // bool

Copy#

Copied!
$ok = File::copy('/path/to/source.txt', '/path/to/copy.txt'); // bool

Both methods return a booltrue on success, false if the operation failed.

Parameter Type Description
from string Source file path
to string Destination file path

Behavior#

  • Parent directories are created automatically if they don't exist.
  • An existing destination file is overwritten.
  • File integrity is verified after a copy.
  • On Android, if a rename fails across file systems, it falls back to copy + delete.

Example#

Move a recording out of temporary storage into a permanent location:

Copied!
use Native\Mobile\Facades\File;
 
$temp = sys_get_temp_dir().'/recording.m4a';
$permanent = storage_path('recordings/recording.m4a');
 
if (File::move($temp, $permanent)) {
// saved
}