开发者

$_FILES is empty

I am using Ajax file upload bt $_FILES is always empty .

this is my php page

    include('../../inc/functions.php');
    $allowdExt = array("mp4","flv");
    $uploaddir = '../../uploads/videos/';
    $filename = basename($_FILES['uploadv']['name']);
    echo "file: $uploaddir".$filename ;
    exit;

        $extension = getExtension($filename);
        $extension = strtolower($extension);

        if(!in_array($extension,$allowdExt)){
            $errors =1;
        }
        else
        {
            $file_name = MakeRandomChars().'.'.$extension ;
            $newname=$uploaddir.$file_name;
            $copied = move_uploaded_file($_FILES['uploadv']['tmp_name'], $newname);
            if (!$copied)
            {
                $errors =1;
            }
        }

        if( $errors == 1){
            echo "0";
        }else{
            echo $file_name;
        }

and this is my jquery code :

$(function(){
    var btnUpload=$('#uploadVideo');
    var status=$('#status');
    new AjaxUpload(btnU开发者_StackOverflowpload, {
        action: 'pages/upload-video.php',
        name: 'uploadv',
        onSubmit: function(file, ext){
             if (! (ext && /^(flv|mp4)$/.test(ext))){ 
                status.text('Only Flv,Mp4 files are allowed');
                return false;

            }
            $('#wait').fadeIn();
        },
        onComplete: function(file, response){
            status.text('');
            if(response != "0"){
                $('#wait').fadeOut();
                $('#videoIcon').fadeIn();
                $('#status').attr('video',response);
            }
        }
    });     
});


With ajaxupload you need to get the data from the raw php input, not from the $_FILES

You can see the sample here: https://github.com/valums/file-uploader/blob/master/server/php.php (the qqUploadedFileXhr class)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜