Package

Nativephp Mobile File

File operations plugin for NativePHP Mobile

Package

nativephp/mobile-file

View on GitHub →

File Plugin for NativePHP Mobile

File operations (move, copy) for NativePHP Mobile applications.

Overview

The File API provides cross-platform file manipulation operations.

Installation

composer require nativephp/mobile-file

Usage

PHP (Livewire/Blade)

use Native\Mobile\Facades\File;

// Move a file
$result = File::move('/path/to/source.txt', '/path/to/destination.txt');

if ($result['success']) {
    echo 'File moved successfully!';
}

// Copy a file
$result = File::copy('/path/to/source.txt', '/path/to/copy.txt');

if ($result['success']) {
    echo 'File copied successfully!';
}

JavaScript (Vue/React/Inertia)

import { File } from '#nativephp';

// Move a file
const result = await File.move('/path/to/source.txt', '/path/to/destination.txt');

if (result.success) {
    console.log('File moved successfully!');
}

// Copy a file
const result = await File.copy('/path/to/source.txt', '/path/to/copy.txt');

if (result.success) {
    console.log('File copied successfully!');
}

Methods

move(string $from, string $to): array

Moves a file from source to destination.

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

Returns:

  • success: bool - Whether the operation succeeded
  • error: string - Error message if operation failed (optional)

copy(string $from, string $to): array

Copies a file from source to destination.

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

Returns:

  • success: bool - Whether the operation succeeded
  • error: string - Error message if operation failed (optional)

Behavior

  • Parent directories are created automatically if they don't exist
  • Existing destination files are overwritten
  • File integrity is verified after copy operations
  • On Android, if rename fails (cross-filesystem), falls back to copy + delete

Examples

Move File to Permanent Storage

use Native\Mobile\Facades\File;

$tempPath = '/var/mobile/Containers/Data/tmp/recording.m4a';
$permanentPath = storage_path('recordings/recording.m4a');

$result = File::move($tempPath, $permanentPath);

if ($result['success']) {
    // File moved successfully
}

Backup File Before Edit

use Native\Mobile\Facades\File;

public function editFile($filePath)
{
    // Create backup
    $backupPath = str_replace('.txt', '_backup.txt', $filePath);
    File::copy($filePath, $backupPath);

    // Proceed with editing...
}

Nativephp Mobile File Related Articles

NativePHP Mobile Security Advisories: Update to 4.6.1 image

NativePHP Mobile Security Advisories: Update to 4.6.1

Read article
NativePHP for Mobile Is Now Free image

NativePHP for Mobile Is Now Free

Read article
NativePHP v4: Build Native iOS and Android UI in Blade image

NativePHP v4: Build Native iOS and Android UI in Blade

Read article
NativePHP for Mobile v1 — Launching May 2 image

NativePHP for Mobile v1 — Launching May 2

Read article
NativePHP for Mobile v1.1: Smaller, Smarter, and Ready to Scale image

NativePHP for Mobile v1.1: Smaller, Smarter, and Ready to Scale

Read article
NativePHP Tutorial: Building a Mac MenuBar application image

NativePHP Tutorial: Building a Mac MenuBar application

Read article

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

NativePHP

The fastest way to build fully native apps for any platform (with AI or not)

NativePHP

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift