-1
我想限制正在上傳的jpg文件,但它不工作。這是我上傳的代碼。在php中的文檔和PDF文件限制
<?php
include "admin/includes/connect.php";
if(isset($_POST['btn-upload']))
{
$file = rand(1000,100000)."-".$_FILES['file']['name'];
$file_loc = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$name = $_POST['name'];
$email = $_POST['email'];
$allowedExts = array("pdf", "doc");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if (($_FILES["file"]["type"] == "application/pdf")
|| ($_FILES["file"]["type"] == "application/doc")
&& ($_FILES["file"]["size"] < 200000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}}
$folder="uploads/";
move_uploaded_file($file_loc,$folder.$file);
$sql="INSERT INTO upload(name,email,file,type,size) VALUES('$name','$email','$file','$file_type','$file_size')";
mysqli_query($conn, $sql);
}
?>
謝謝......... – Zeshan
@Zeshan歡迎好友 –