file_exist nie działa WHEN PLACED wewnątrz funkcji php
Szukałemprawie podobne pytania ale żaden z nich nie dał mi właściwej odpowiedzi. Mam w pełnipracujący tutaj file_exist code in if else. ale kiedy umieściłem go w funkcji, już nie działa. Oto kod:
if (file_exists($_SERVER['DOCUMENT_ROOT']."/Project/events/folder-01/event-01.txt")) {
$myFile = ($_SERVER['DOCUMENT_ROOT']."/Project/events/folder-01/event-01.txt");
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
echo "The file exists." ;
}
else {
echo "The file $filename does not exist";
}
Kiedy umieszczam go w funkcji, która nie działa:
function readexisting(){
if (file_exists($_SERVER['DOCUMENT_ROOT']."/Project/events/folder-01/event-01.txt")) {
$myFile = ($_SERVER['DOCUMENT_ROOT']."/Alchemy/events/folder-01/event-01.txt");
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
echo "The file exists." ;
}
else {
echo "The file $filename does not exist";
}
}
Chcę także wywołać funkcję w zdarzeniu kliknięcia obrazu. Oto kod, jeśli to pomoże:
<div class="Thumb popup_element shadow clearfix" id="u2413"><!-- group -->
<img class="grpelem" id="u2471" alt="This Week's Events" src="images/blank.gif" onclick="readexisting()"/><!-- state-based BG images -->
</div>
Mam nadzieję, że możesz mi w tym pomóc. z góry bardzo dziękuję!