开发者

Can't find uploaded files in temp directory after script execution ends

I am trying out a tutorial on W3 schools to learn how to create forms for PHP uploads.

To this end, I have the following two files as shown on W3 schools:

The HTML file:

<html>
<body>
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html> 

and the corresponding PHP file as follows:

<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Siz开发者_JAVA百科e: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
?> 

When I save the above files onto my localhost, and execute the up.html file, the PHP produces an output as follows:

Upload: AddTrustExternalCARoot.crt

Type: application/x-x509-ca-cert

Size: 1.4853515625 Kb

Stored in: /tmp/phpK0YqyL

Unfortunately, I cannot seem to find this /tmp/phpK0YqyL.

Can anyone suggest where this file could possibly be located?

In reality, I would also like to know how one could specify the path to directly upload the file to (presumably this would be somewhere in $_FILES array).


The /tmp/ folder is a folder to temporarily store the file for processing or reading. If you want to access the file later on, you need to save the file to the server with the move_uploaded_file function


Temporary uploaded files are removed when the script execution ends.


remember to set /temp/folder for read write files

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜