I'm really just messing around and learning more about PHP, but I stumbled upon something that kinda threw me for a loop. I'm hoping I could just get some insight on the conundrum.
Basically I'm just trying to discovering mimetypes for uploaded images - and like the subject line asks: if upload_tmp_dir has no value, where (in the internets) do my temp files end up? I should mention that it does tell me my mimetypes! So partly a success!
And here are some of my specs: I'm running PHP 5.3+ and my upload_tmp_dir has no value - I did read another post from 2008 that suggested var_dump might help but it only returns an empty array.
<?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>
Thanks everyone!
It will most likely use the system's tmp directory. But to really find out you should inspect the output of <?php phpinfo() ?>
. You can put it onto a info.php
file or similar and open that file's URL in your browser. It will tell you all the configuration values; even defaults.
You can also use sys_get_temp_dir()
to find out the location of the temp directory.
I was looking for this answer too. I found my php.ini
file in /etc
and inside:
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
This seems to indicate /tmp
if unspecified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With