Probleme mit der Verwendung von PHP Swift Mailer
-
28-10-2019 - |
Frage
Was ich getan habe:
- ) Heruntergeladen Swift-4.1.5.tar
- ) Extrahiert es
- ) Mit FileZilla auf meinen Host in / public_html / domain / lib hochgeladen
- ) Mit dem folgenden Code ein neues Skript erstellt.
- ) Öffnete es im Browser und ich bekam den folgenden Fehler unten
Meine Frage ist also, wie bekomme ich den Fehler, dass die Datei nicht existiert, wenn sie zu 100% vorhanden ist?Danke!
<?php require_once '/public_html/domain/lib/swift_required.php'; ?>
Warnung: require_once (/public_html/domain/lib/swift_required.php) [function.require-einmal]: Stream konnte nicht geöffnet werden: Keine solche Datei oder kein solches Verzeichnis in /home/myuser/public_html/domain/email.php onZeile 5
Schwerwiegender Fehler: require_once () [function.require]: Fehler beim Öffnen erforderlich '/public_html/domain/lib/swift_required.php' (include_path= '.: / usr / lib / php: / usr / local / lib /php ') in /home/myuser/public_html/domain/email.php in Zeile 5
Hier ist ein Screenshot meines Verzeichnisses von FileZilla. http://i.imgur.com/Zsy8y.jpg
Lösung
Das ist falsch:
// this is absolute path, just like /home/user or /var/www
require_once '/public_html/domain/lib/swift_required.php';
Verwenden Sie stattdessen:
// this is relative path to the current file
require_once 'public_html/domain/lib/swift_required.php'; //notice: no '/' in the beggining
ODER:
// 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';
ODER:
// 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';