[英]Upper or Lower Case Issue using get_file_contents php
I am using a PHP GET method to grab a file name that then is placed in a get_file_contents command. 我正在使用PHP GET方法来获取文件名,然后将其放置在get_file_contents命令中。 If it is possible, I would like to ignore letter case so that my URL's are cleaner.
如果可能的话,我想忽略字母大小写,以便我的URL更加整洁。
For instance, example.com/file.php?n=File-Name will work but example.com/file.php?n=file-name will not work using the code below. 例如,example.com / file.php?n =文件名将起作用,但example.com/file.php?n=文件名将无法使用下面的代码。 I feel like this should be easy but I'm coming up dry.
我觉得这应该很容易,但是我要干了。 Any thoughts?
有什么想法吗?
$file = $_GET['n'];
$file_content = file_get_contents($file);
The Linux filesystem is case sensitive. Linux文件系统区分大小写。 If you want to do case insensitive matching against files that already exist on the user's machine, your only option is to obtain a directory listing and do case-insensitive comparison.
如果要对用户计算机上已经存在的文件进行不区分大小写的匹配,则唯一的选择是获取目录列表并进行不区分大小写的比较。
But you don't explain where the download URLs come from. 但是您没有解释下载URL的来源。 If you already know the correct filenames and you want to generate prettier URLs, you can keep a list of the true pathnames and look them up when you receive a case-normalized one in a URL (you could even rename them completely, obfuscate, etc.)
如果您已经知道正确的文件名,并且想要生成更漂亮的URL,则可以保留真实路径名的列表,并在URL中收到大小写标准化的路径名时查找它们(甚至可以完全重命名,混淆等)。 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.