简体   繁体   English

无法使用PHP打开日志文件

[英]Can't open log file using PHP

I'm trying to open a log file located on my local machine from my web application hosted on websitepanel, but I keep getting this error message: 我正在尝试从网站面板上托管的Web应用程序打开位于本地计算机上的日志文件,但是我一直收到以下错误消息:

Warning: file(file:///C:/Program Files/FileMaker/FileMaker Server/Logs/Access.log) [function.file]: failed to open stream: No such file or directory in E:\\HostingSpaces\\ssd19aaron\\testproject.tureckidesign.com\\wwwroot\\application\\models\\logsmodel.php on line 91 警告:file(file:/// C:/ Program Files / FileMaker / FileMaker Server / Logs / Access.log)[function.file]:无法打开流:E:\\ HostingSpaces \\ ssd19aaron \\中没有此类文件或目录第91行的testproject.tureckidesign.com \\ wwwroot \\ application \\ models \\ logsmodel.php

This is the code: 这是代码:

$filename = 'C:/Program Files/FileMaker/FileMaker Server/Logs/Access.log';

$lines = file($filename, FILE_IGNORE_NEW_LINES);

Why won't the file open when I visit the site? 为什么当我访问网站时文件无法打开?

Because you try to get the file from C:/. 因为您尝试从C:/获取文件。 Host your file on a logs folder inside your web application and edit the URL like this: 将文件托管在Web应用程序内的日志文件夹中,然后按如下所示编辑URL

$filename = 'logs/access.log';

The computer provided by the Arvixe hosting service does not have the same file system as your local computer. Arvixe托管服务提供的计算机与本地计算机没有相同的文件系统。 You can't give it a file path for one computer and expect a program running on a different computer to find it. 您不能为它提供一台计算机的文件路径,而希望在另一台计算机上运行的程序可以找到它。 That is like trying to navigate Berlin using a map of Paris. 这就像尝试使用巴黎地图导航柏林。

Generally speaking, to get a file from an HTTP client to an HTTP server you will use a form with a file input. 一般而言,要将文件从HTTP客户端获取到HTTP服务器,您将使用带有文件输入的表单。

<form action="http://Arvixe-hosting-service/example.php" 
      method="post" 
      enctype="multipart/form-data">

<label>Log file <input type="file" name="log"> </label>
<input type="submit">

</form>

You can then read the file from 然后,您可以从

$_FILES['log']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM