获取已发布文件的文件大小不起作用

时间:2015-08-15 06:13:07

标签: php jquery ajax

我正在使用ajax将文件发送到PHP文件。所有的事情都可以,但是大小。

jquery:

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>

    var origin1 = new google.maps.LatLng(9.6667, 80.0000);
    var destinationA = new google.maps.LatLng(9.6689, 80.0059);



    function calculateDistances() {


        var service = new google.maps.DistanceMatrixService();
        service.getDistanceMatrix(
            {
                origins: [origin1],
                destinations: [destinationA],
                travelMode: google.maps.TravelMode.DRIVING,
                unitSystem: google.maps.UnitSystem.METRIC,
                avoidHighways: false,
                avoidTolls: false
            }, callback);

    }

    function callback(response, status) {
        if (status != google.maps.DistanceMatrixStatus.OK) {
            alert('Error was: ' + status);
        } else {
            var origins = response.originAddresses;


            for (var i = 0; i < origins.length; i++) {
                var results = response.rows[i].elements;
                for (var j = 0; j < results.length; j++) {
                    alert(results[j].distance.text);
                }
            }
        }
    }


</script>

HTML:

<script>
$('#submitshout').click(function () {
    $('.shoutinputhover').show();
    var formDatashout = new FormData($('#shoutform')[0]);
    $.ajax({
        url: "../pages/sn/ajax/submitshout.php",
        type: "POST",
        data: formDatashout,
        success: function (msg) {
            alert(msg);
            if (msg == 'update') {
                addshout();
            }
        },
        cache: false,
        contentType: false,
        processData: false
    });
   });
</script>

和PHP文件:

    <form method="post" enctype="multipart/form-data" id="shoutform" >
    <textarea  class="ordinaryinput" style="width: 100%;height: 60px" id="shouttxtarea" name="shouttxtarea"></textarea>
    <div class="shoutaddimage">
    <input type="file" name="shoutaddimageer"  id="shoutaddimageer"  style="width: 100%"   >
    </div>
    </form>

如果我在上面的php代码中放置名称类型而不是大小,它将准确地返回文件类型或文件名,但它不适用于大小并且它不返回任何内容!!!!

因为我可以获得文件类型和文件名,这意味着发送表单正常。但是大小有什么不对吗?

1 个答案:

答案 0 :(得分:0)

如果您的文件上传因任何原因中止,则没有大小 检查将返回的内容:$_FILES['shoutaddimageer']['error']
以下是错误列表:http://php.net/manual/en/features.file-upload.errors.php