Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php没有进入foreach循环_Php_Debugging - Fatal编程技术网

php没有进入foreach循环

php没有进入foreach循环,php,debugging,Php,Debugging,我发誓这个剧本昨晚做得很好,但今天不行。但它没有进入foreach循环,我不知道为什么。即使我选择一个文件并单击submit,$\u FILES数组也是空的 基本上,这个脚本有一个文件输入标记,使用jquery,如果用户选择一个文件,它会添加另一个文件输入标记。单击submit按钮时,将调用PHP <?php //used for firePHP include('PHP/FirePHPCore/fb.php'); ob_start(); $success = false; $erro

我发誓这个剧本昨晚做得很好,但今天不行。但它没有进入foreach循环,我不知道为什么。即使我选择一个文件并单击submit,$\u FILES数组也是空的

基本上,这个脚本有一个文件输入标记,使用jquery,如果用户选择一个文件,它会添加另一个文件输入标记。单击submit按钮时,将调用PHP

<?php
//used for firePHP
include('PHP/FirePHPCore/fb.php');
ob_start();


$success = false;
$error = "";
$allowable_types = array(
    'image/jpeg',
    'image/pjpeg',
    'image/jpg',
    'image/jpe',
    'image/gif',
    'image/png'
);



#################################################################
//NOT GETTING INSIDE THE FOREACH LOOP. $_FILES array is always null
##################################################################
//loops through the files that the user has chosen to be uploaded them and moves them to the Images/uploaded folder
foreach($_FILES as $key => $value) {
    if(!empty($_FILES[$key])) {
        if($_FILES[$key]['error'] == 0) {
            if(in_array($_FILES[$key]['type'], $allowable_types) && ($_FILES[$key]['size'] < 5000000)) {
                if(!file_exists("Images/uploaded/".$_FILES[$key]['name'])) {
                    move_uploaded_file($_FILES[$key]['tmp_name'], "Images/uploaded/".$_FILES[$key]['name']);
                    $success = true;
                } else {
                    $error = "<h3 class=\"bad\">At least one of the files already exists</h3>";
                }
            } else {
                $error = "<h3 class=\"bad\">At least one of the files you've selected is either too large or not the correct file type</h3>";
            }
        } elseif($_FILES[$key]['error'] == 4) { 

        } else {
            $error = "<h3 class=\"bad\">An error occurred while trying to upload one of the files</h3>";
        }
    } else {
        $error = "<h3 class=\"bad\">You need to select a file</h3>";
    } 
}



?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="1205">
<link rel="stylesheet" type="text/css" href="CSS/reset.css" />
<link rel="stylesheet" type="text/css" href="CSS/uploadFile.css" />
<link rel="stylesheet" type="text/css" href="CSS/galleria.css" />
<script type="text/ecmascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="JS/galleria.jquery.js"></script>

<script type="text/javascript"> 


    $(document).ready(function() { 

        var i = 1;

        //gives the first li the class .active so that it shows the large version as if it's been clicked. 
        //-- used for the gallery page
        $('#content ul.gallery li:first-child').addClass('active');

        //fades the links on hover -- used for the nav links
        $('#header ul li a').hover(function() {
            $(this).fadeTo(300, 0.3);
        },function() {
            $(this).fadeTo(300, 1);
        });



            $('input:file:last').live('change',function() {
                var file = $(this).val();
                if(file !== null && file !== "") {
                    if(i < 6) {
                        $(this).after("<input type=\"file\" name=\"uploadedFile"+i+"\" value=\"\" />");
                        i++;
                    }
                }
            });
    }); 
</script>
<meta name="keywords" content="Steph Mcclisch Photography Portfolio Pictures" />
<title>Steph McClish Photography</title>
</head>

<body>
<div id="floater"></div>
<div id="wrapper">

    <div id="content">
        <?php 
        if($success) {
        echo "<h3 class=\"good\">Files Uploaded Successfully!</h3>";
        } elseif ($error) {
        echo $error;
        }
    ?>
        <h4>Choose the files to be uploaded</h4>
        <form action="<?php $_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
            <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
            <input type="file" name="uploadedFile0" value="" />
            <button type="submit" name="login">Submit</button>
        </form>
        <h5><a href="PHP/Manage.php">Manage Files/Folders</a></h5>
    </div>


</div>
</body>
</html>

$(文档).ready(函数(){
var i=1;
//为第一个li提供class.active,以便它显示大版本,就好像它被单击一样。
//--用于图库页面
$('#content ul.gallery li:first child').addClass('active');
//在悬停时淡入链接-用于导航链接
$('#标题ul li a')。悬停(函数(){
美元(本).fadeTo(300,0.3);
},函数(){
美元(本).fadeTo(300,1);
});
$('input:file:last').live('change',function()){
var file=$(this.val();
如果(文件!==null&&file!==“”){
如果(i<6){
$(此)。在(“”)之后;
i++;
}
}
});
}); 
斯蒂芬·麦克利什摄影
选择要上载的文件

这一切都与我的Wamp服务器设置有关。在菜单栏的wamp图标上,我进入了php>php设置>文件上传。只要点击一次,它就解决了所有问题

在windows XP、SP2上,资源管理器有时无法上载没有扩展名的文件

在这种情况下,$\u文件数组为空。微软称这是一项安全功能(!)

我们能想到的唯一解决方案是强制上传的文件具有扩展名