The Linux configuration /var/www/html/upload permission is 777. When uploading files, it also prompts that there is no permission. Why is this?
phpcn_u56297
phpcn_u56297 2017-11-07 18:46:12
0
0
2654

The result is like this: 2017-11-07 18-41-31 的屏幕截图.png


The code is as follows:

form.html

<html>
<head>
<meta charset="utf-8">
<title>php Chinese website (php.cn)</title>
</head>
<body>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">File name:< ;/label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value=" Submit">
</form>
</body>
</html>
~****************** *************************************************** ******************************************

upload_file.php

      <?php
// Allowed uploaded image suffix
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode( ".", $_FILES["file"]["name"]);
echo $_FILES["file"]["size"];
$extension = end($temp); // Get File extension name
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"][ "type"] == "image/png"))
&& ($_FILES["file"]["size"] < 204800) // Less than 200 kb
&& in_array($extension, $allowedExts ))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"][" error"] . "<br>";
}
else
{
echo "Upload file name: " . $_FILES["file"]["name"] . "< br>";
echo "File type: " . $_FILES["file"]["type"] . "<br>";
echo "File size: " . ($_FILES["file "]["size"] / 1024) . " kB<br>";
echo "The location where the file is temporarily stored: " . $_FILES["file"]["tmp_name"] . "<br>" ;

// Determine whether the file exists in the upload directory under the current directory
// If there is no upload directory, you need to create it. The upload directory permission is 777
if (file_exists("upload/ " . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " The file already exists. ";
}
else
{
// If the file does not exist in the upload directory, upload the file to the upload directory

                       move_uploaded_file($_FILES["file"][ "tmp_name"], "upload/" . $_FILES["file"]["name"]);
echo "The file is stored in: " . "upload/" . $_FILES["file"]["name "];
}
}
}
else
{
echo "Illegal file format";
}
?>


phpcn_u56297
phpcn_u56297

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template