KTVSingle/app/Console/Commands/TestFtpConnection.php
allen.yan 9237edb228 單機版 v0.0.10 20250625
song_library_cache id 不正確問題
2025-06-25 10:52:24 +08:00

40 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class TestFtpConnection extends Command
{
protected $signature = 'ftp:test';
protected $description = '測試 FTP 連線、上傳、下載、刪除';
public function handle()
{
$disk = Storage::disk('ftp_test');
$testFile = 'laravel_ftp_test.txt';
$testContent = '這是 Laravel 的 FTP 測試檔案';
// 嘗試上傳
$this->info("🔼 上傳中...");
if (!$disk->put($testFile, $testContent)) {
return $this->error("❌ 上傳失敗");
}
// 嘗試讀取
$this->info("📥 下載檢查...");
$content = $disk->get($testFile);
if ($content !== $testContent) {
return $this->error("❌ 檔案內容不符");
}
// 嘗試刪除
$this->info("🗑️ 刪除測試檔案...");
if (!$disk->delete($testFile)) {
return $this->error("❌ 刪除失敗");
}
$this->info("✅ FTP 測試成功!");
}
}