Problemas com o uso de PHP Swift Mailer
-
28-10-2019 - |
Pergunta
O que eu fiz:
- ) Swift-4.1.5.tar baixado
- ) Extraiu-o
- ) Carregado em meu host em / public_html / domain / lib usando FileZilla
- ) Fez um novo script usando o código abaixo.
- ) Abri no navegador e recebi o seguinte erro abaixo
Então, minha pergunta é: como recebo o erro de que o arquivo não existe se estiver 100% lá?Obrigado!
<?php
require_once '/public_html/domain/lib/swift_required.php';
?>
Aviso: require_once (/public_html/domain/lib/swift_required.php) [function.require-once]: falha ao abrir o fluxo: Não existe esse arquivo ou diretório em /home/myuser/public_html/domain/email.phplinha 5
Erro fatal: require_once () [function.require]: Falha ao abrir necessário '/public_html/domain/lib/swift_required.php' (include_path= '.: / usr / lib / php: / usr / local / lib /php ') em /home/myuser/public_html/domain/email.php na linha 5
Aqui está uma captura de tela do meu diretório do FileZilla. http://i.imgur.com/Zsy8y.jpg
Solução
Isso está errado:
// this is absolute path, just like /home/user or /var/www
require_once '/public_html/domain/lib/swift_required.php';
Use em seu lugar:
// this is relative path to the current file
require_once 'public_html/domain/lib/swift_required.php'; //notice: no '/' in the beggining
OU:
// so use this one if you know the whole path to the file
require_once ABSOLUTE_PATH_TO . 'public_html/domain/lib/swift_required.php';
OU:
// or use this one if you don't know the whole path
// or if the path will change (dev machine and production machine)
require_once dirname(__FILE__) . RELATIVE_PATH_TO . 'public_html/domain/lib/swift_required.php';
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow