如果upload_tmp_dir没有价值...我的临时文件去哪儿了?-- 实验
2022-08-30 16:11:01
我真的只是在四处乱搞,学习更多关于PHP的知识,但我偶然发现了一些东西,有点让我陷入了循环。我希望我能对这个难题有所了解。
基本上,我只是试图发现上传图像的哑剧类型 - 就像主题行问的那样:如果upload_tmp_dir没有价值,那么我的临时文件最终会在哪里(在互联网上)?我应该提到,它确实告诉我我的哑剧类型!所以部分成功!
以下是我的一些规范:我正在运行PHP 5.3 +,我的upload_tmp_dir没有价值 - 我确实阅读了2008年的另一篇文章,建议var_dump可能会有所帮助,但它只返回一个空数组。
<?php
if(empty($_FILES)){
echo "nothing in files array -- ignore warning, testing only" . "<br /><br />";
}
$finfo = new finfo(FILEINFO_MIME_TYPE);
$fileContents = file_get_contents($_FILES['upload']['tmp_name']); // check tmp dir for
$mimeType = $finfo->buffer($fileContents);
echo $mimeType . "<br /><br />";
echo var_dump($_FILES) . "<br /><br />";
?>
<form action="" method="post" enctype="multipart/form-data">
<p>
<label id="upload">Select a file to upload:
<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
<input type="file" id="upload" name="upload">
</label>
</p>
<p>
<input type="hidden" name="action" value="upload">
<input type="submit" value="Submit">
</p>
</form>
谢谢大家!