PHP上传多个图像返回大写错误

时间:2015-03-16 19:32:56

标签: javascript php html input

上传多张图片时,我发现这个奇怪而烦人的错误。 这不会发生上传一个图像!!!

如果文件是小写的,它可以正常工作,但如果它们是大写的,它只会在ajaxSubmit成功选项上返回Error。

我有代码来降低字符直接跳过php代码并在成功选项上返回“Error”。

这是html输入

<input name="gb[]" type="file" class="j_gallery" multiple="multiple" accept="image/*" />

不确定是否需要更多代码,因为它完全跳过了php ..

任何提示?

编辑:

$('form[name="editpost"]').submit(function(){   
        var form = $(this);
        var bar = $('.j_editposts .progress');
        var per = $('.j_editposts .progress .bar');
        $(this).ajaxSubmit({
            url: url,
            data: {acao: 'posts_update'},
            beforeSubmit: function(){
                $('.accept').fadeOut("fast");
                $('.j_editpostimgload').fadeIn("fast");
                $('.j_editposts .title img').fadeIn("fast");
            },
            uploadProgress: function(evento, posicao, total, completo){

            },
            success: function(resposta){
                alert(resposta);
                }   
            },
            complete: function(){
                $('.j_editpostimgload').fadeOut("fast");
                $('.j_editposts .title img').fadeOut("fast");
                bar.fadeOut("fast",function(){
                    $('.accept').fadeIn("fast");
                });
            }
        });
        return false;
    });

PHP

case 'posts_update':
        sleep(1);
        $postid = mysql_real_escape_string($_POST['postid']);

        (...code)

        //Validação da capa
        if($_FILES['cover']['tmp_name']):

        endif;

        //Validação da imagem real
        if($_FILES['realcover']['tmp_name']):

        endif;

        //Validação da galeria

        if($_FILES['gb']['tmp_name']){
            $count = count($_FILES['gb']['tmp_name']);  
            $gb = $_FILES['gb'];
            $pasta = '../../uploads/';

            //gerador de pastas
            $m = date('m');
            $y = date('Y');
            if(!file_exists($pasta.'gallery')): mkdir($pasta.'gallery',0755);   endif;
            if(!file_exists($pasta.'gallery/'.$y)): mkdir($pasta.'gallery/'.$y,0755);   endif;
            if(!file_exists($pasta.'gallery/'.$y.'/'.$m)): mkdir($pasta.'gallery/'.$y.'/'.$m,0755);endif;

            for($i=0;$i<=$count;$i++):
                $ext = strrchr($gb['name'][$i],'.');
                $ext = strtolower($ext);

                $baseDir = 'gallery/'.$y.'/'.$m.'/';
                $capaName = $baseDir.$postid.'-'.$i.time().$ext;

                $extePerm = array('image/jpeg','image/pjpeg','image/png','image/gif');

                if(in_array($gb['type'][$i],$extePerm)):
                    $cadastra = array('post_id' => $postid, 'imagem' => $capaName, 'uploaded' => date('Y-m-d H:i:s'));
                    create('posts_gallery',$cadastra);
                    uploadImage($gb['tmp_name'][$i],$capaName,800,$pasta);
                    echo ' sendgb';
                endif;
            endfor;
        }
        update('posts',$f,"id = '$postid'");
    break;

0 个答案:

没有答案