我需要从打开的目录中拯救我的 .php 文件
我有一个打开的目录,没有 index.html 文件。如您所知,这是一个坏主意,因为人们可以下载我的文件。对我来说幸运的是,我无法再访问 FTP,但我需要一个可以从目录中看到的 .php 文件。右键单击并将其保存到我的桌面会生成一个 0kb 文件。为什么我可以从此目录保存图像、mp3 或其他文件,但不能保存 .php 文件?
有什么我可以做的吗?
编辑:看来我需要找到一种方法来通过 FTP 访问目录或域。我必须联系主机提供商并进行密码重置或类似操作
I have an open directory which does not have an index.html file. As you know, this is a bad idea as people can download my files. Luckily for me, I don't have access to the FTP anymore but I need a .php file I can see from the directory. Right clicking and saving it to my desktop results in a 0kb file. Why can I save an image, mp3, or other file from this directory, but not .php files?
Is there anything I can do??
EDIT: So it seems like I'll need to find a way to get FTP access to the directory or domain. I'll have to contact the host provider and do a password reset or some such
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
HTTP 实际上并不让您直接下载文件。它只是让你向服务器发送请求,服务器不需要给你任何东西。有时,这些请求会导致服务器向您传递一个文件,但对于 php,该请求会导致服务器运行 php 并返回结果。
所以,不,仅通过 HTTP 无法执行任何操作。您必须以其他方式(FTP、SCP、SSH shell 等)访问服务器。
HTTP doesn't actually let you download files directly. It just lets you send a request to the server, the server doesn't have to give you anything. Sometimes, these requests result in the server handing you a file, but in the case of php, the request causes the server to run the php and return the result.
So, no, there is nothing you can do via HTTP alone. You have to get access to the server in some other way (FTP, SCP, SSH shell, etc...).
当您尝试“保存”文件时,提供文件服务的 Web 服务器可能正在处理 php。为了获取这些文件,您需要对原始目录进行某种文件访问。
有些服务器确实通过附加服务提供对 php 源代码的访问,但您很可能无法获得该服务。你被困在没有来源的地方。我会联系您的提供商以获取 FTP 和/或 Web 文件访问权限。
The web server that is serving the files is probably processing the php when you're trying to "save it". In order to obtain the files you'll need some kind of file access to the original directory.
Some servers do provide access to the php source via additional service, but you're more than likely not able to get that. You're stuck without the source. I'd contact your provider to get FTP and/or web file access.
PHP 文件正在执行。您无法通过 HTTP 下载原始源代码。
The PHP file is being executed. You cannot download the raw source code over HTTP.
PHP 文件在发送到浏览器之前由服务器进行评估。如果您尝试下载的文件没有产生任何输出,则不会向您的浏览器发送任何输出,并且生成的文件大小将为 0 字节。图像、mp3 文件和其他文件都会被下载,然后在客户端进行评估。
PHP files are evaluated by the server before being sent to the browser. If the file you're trying to download doesn't produce any output, your browser will not be sent any and the resulting file will be 0 bytes in size. Images, mp3 files, and others are all downloaded and then evaluated client-side.
不,如果没有 FTP 或其他对文件的直接访问,您将无能为力。当您通过 HTTP 从服务器请求 PHP 文件时,它被配置为执行该文件并显示结果,而不是文件内容。无法通过直接 HTTP 访问在正确配置的服务器上查看 PHP 文件的源代码。我说正确配置是因为可以更改 httpd.conf 中的映射信息以防止服务器执行文件,在这种情况下您将看到实际的文件内容。
No, there is nothing you can do without FTP or some other direct access to the files. When you request a PHP file from the server over HTTP, it's configured to execute that file and display the result, not the file contents. There is no way to see the source code of PHP files on a properly configured server with direct HTTP access. I say properly configured because it's possible to change the mapping information in, for example, httpd.conf to prevent the server from executing the files, in which case you would see the actual file contents.