PHP中的文件上传大小甚至不到2MB

问题描述:

我想将图像上传到某个文件夹,但只有上传大小小于20Kb的图像。我无法将文件上传到2Mb,因为它在默认情况下在php.ini文件中。我已更改的值为PHP中的文件上传大小甚至不到2MB

upload_max_filesize=40M 
post_max_size=40M 

我不知道问题出在哪里。我正在使用Xammp服务器

<?php 
include_once("connect.php"); 
session_start(); 
if(isset($_POST['subm'])) 
{ 
    extract($_POST); 
    $_SESSION['artsubmit_error'] = ""; 
    $title1 = $_POST['title']; 
    $intro1 = $_POST['intro']; 
    $descr1 = $_POST['descr']; 

$imgname= $_FILES["file"]["name"]; 
$artid = "".$_SESSION['logged_user_email'].""; 

$allowedExts = array("GIF", "JPEG", "JPG", "PNG"); 
$temp = explode(".", $_FILES["file"]["name"]); 
$extension = end($temp); 
echo "$extension"; 
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"] < 10000000) 
&& in_array($extension, $allowedExts)) 
{ 

    if(!is_dir("Article/".$artid."")) 
    { mkdir("Article/".$artid.""); } 
    mkdir("Article/".$artid."/".$title1.""); 
    move_uploaded_file($_FILES["file"]["tmp_name"],"article/".$artid."/".$title1."/".$_FILES["file"]["name"].""); 
    } 
    else 
    { 
    print "<br> ".$_FILES["file"]["type"]."";print "<br>"; 
    print "<h2>Invalid image. File should be less than 2MB <h2>"; 
    header("refresh: 2;url=articlestore.php"); exit; 
    } 

    $parag = nl2br("$descr1"); 
    $query = "insert into article values('','$userid','$title1','$intro1','$parag','$imgname',NOW())"; 
    mysql_query($query) or die("unsucessfull"); 

    $_SESSION['artsubmit_error'] = "Article submitted. Post another"; 
    header("Location: articlestore.php");exit; 
    } 
    ?> 
+0

返回错误 '$移动= move_uploaded_file($ _ FILES [工作正常”文件 “] [” tmp_name的值 “],” 文章/".$ artid的数据类型 “/” $ TITLE1 “/” $ _ FILES [ “文件”] [ “名称”] “”)。。。 ($移动){ 回显“成功上传”; } else { echo“因错误#未上传”$ _ FILES [“file”] [“error”]; }' –

问题已解决。我只是改变

$allowedExts = array("gif", "jpeg", "jpg", "png"); 

$allowedExts = array("gif", "jpeg", "jpg", "png","GIF","JPEG","JPG","PNG"); 

现在它为所有类型的图像,甚至大小大于2MB