PHP阅读上传的文件内容问题
我上传了一个txt文件,我做了以下操作
print_r($_FILES);输出是
Array ( [up_file] => Array ( [name] => upload.txt [type] => text/plain [tmp_name] => /tmp/phpbyrYwN [error] => 0 [size] => 26 ) )当我做了以下
$tmp_file_path = strtolower($_FILES['up_file']['tmp_name']); //rename file $file_content = file_get_contents($tmp_file_path);$ tmp_file_path返回me / tmp / phpbyrYwN但$ file_content什么都没有返回,我通过ssh转到root并检查/ tmp但是没有看到名字/ tmp / phpbyrYwN的任何文件,我该怎么做才能解决这个问题。
我应该在代码的任何部分中声明上传文件的默认目录吗?
PHP reading uploaded file content issue
I upload a txt file, and I did the following
print_r($_FILES);The output was
Array ( [up_file] => Array ( [name] => upload.txt [type] => text/plain [tmp_name] => /tmp/phpbyrYwN [error] => 0 [size] => 26 ) )When I did the following
$tmp_file_path = strtolower($_FILES['up_file']['tmp_name']); //rename file $file_content = file_get_contents($tmp_file_path);The $tmp_file_path return me /tmp/phpbyrYwN but $file_content return nothing, I went to root via ssh and check /tmp but did not see any file by the name /tmp/phpbyrYwN , what should I do to resolve this.
Should I state a default directory for uploaded file in any part of the code or ?
最满意答案
您的文件系统似乎区分大小写,
并尝试读取较低的文件名。
尝试没有strtolower :
<?php $tmp_file_path = $_FILES['up_file']['tmp_name']; $file_content = file_get_contents($tmp_file_path);your file system seem to be case-sensitive,
and you try to read the lower-cased file name.
try it without the strtolower:
<?php $tmp_file_path = $_FILES['up_file']['tmp_name']; $file_content = file_get_contents($tmp_file_path);更多推荐
发布评论