The following is the code for uploading files, but when I upload web script languages such as php, asp, jsp, a 500 error occurs, and other suffix files are normal
But When I use phpstudy2016, the upload is normal. I feel that it may be a problem with the apache configuration file
So I would like to ask if anyone has encountered similar problems and can you come out to discuss it
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>sqlin.php</title> </head> <body> <form action="" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="scfile" id="file" /> <input type="submit" value="上传" /> </form> </body> </html> <?php $temp = explode(".", $_FILES["scfile"]["name"]); echo $_FILES["scfile"]["size"]; $extension = end($temp); // 获取文件后缀名 if ($_FILES["scfile"]["size"] < 204800000) { if ($_FILES["scfile"]["error"] > 0) { echo "错误:: " . $_FILES["scfile"]["error"] . "<br>"; } else { echo "上传文件名: " . $_FILES["scfile"]["name"] . "<br>"; echo "文件类型: " . $_FILES["scfile"]["type"] . "<br>"; echo "文件大小: " . ($_FILES["scfile"]["size"] / 1024) . " kB<br>"; echo "文件临时存储的位置: " . $_FILES["scfile"]["tmp_name"] . "<br>"; // 判断当期目录下的 upload 目录是否存在该文件 // 如果没有 upload 目录,你需要创建它,upload 目录权限为 777 if (file_exists("upload/" . $_FILES["scfile"]["name"])) { echo $_FILES["scfile"]["name"] . " 文件已经存在。 "; } else { // 如果 upload 目录不存在该文件则将文件上传到 upload 目录下 move_uploaded_file($_FILES["scfile"]["tmp_name"], "upload/" . $_FILES["scfile"]["name"]); echo "文件存储在: " . "upload/" . $_FILES["scfile"]["name"]; } } } else { echo "非法的文件格式"; } ?>
路过2018-03-08 08:37:12
Look at the file upload configuration in your php.ini file. There are some upload file configurations around line 800