0) { // Use the uploaded file's temp path directly $temp_path = $_FILES['file']['tmp_name']; // Get actual MIME type from file content (more secure than trusting browser) $actual_mime_type = mime_content_type($temp_path); // Sanitize filename - remove path info and dangerous characters $safe_filename = basename($_FILES['file']['name']); $safe_filename = preg_replace('/[^a-zA-Z0-9._-]/', '_', $safe_filename); $fileData = [ 'file' => new CURLFile($temp_path, $actual_mime_type, $safe_filename) ]; $additionalData = $_POST; // Include any additional POST data $token = createCommunicationToken($_SESSION['authorization']['userkey']); $response = ioAPIv2_FileUpload('/v2/marketing_upload/', $fileData, $additionalData, $token); // No need to unlink since we didn't move the file } else { $response = json_encode(['error' => 'No file uploaded or upload error']); } header('Content-Type: application/json'); echo $response; exit; } // Marketing delete if ($action === 'marketing_delete' && $_SERVER['REQUEST_METHOD'] === 'POST') { $payload = ['file_id' => $_POST['file_id'] ?? '']; $response = ioServer('/v2/marketing_delete', json_encode($payload)); header('Content-Type: application/json'); echo $response; exit; } // Marketing update if ($action === 'marketing_update' && $_SERVER['REQUEST_METHOD'] === 'POST') { $payload = ['file_id' => $_POST['file_id'] ?? '']; // Only include fields that were actually sent if (isset($_POST['title'])) { $payload['title'] = $_POST['title']; } if (isset($_POST['folder_id'])) { $payload['folder_id'] = $_POST['folder_id']; } if (isset($_POST['tags'])) { $payload['tags'] = $_POST['tags']; } $response = ioServer('/v2/marketing_update', json_encode($payload)); header('Content-Type: application/json'); echo $response; exit; } } catch (Exception $e) { header('Content-Type: application/json'); http_response_code(500); echo json_encode(['error' => $e->getMessage()]); exit; } } template_header('Marketing', 'marketing'); ?>

Loading files...