图像没有上传到服务器-PHP上

时间:2015-10-10 17:19:38

标签: javascript php html

我试图将图片用作输入type = file的标签。我想上传对话框打开uplon点击图片。这似乎工作正常。但是在提交文件后,文件没有通过服务器,只有文件名才能通过。在打印文件大小/ mime时,我得到0 / null。 这是代码:

<form enctype="multipart/form-data" action="uploadimage.php" method="post">
<input style="display:none;" name="image" id="img-input" type='file' onchange="readURL(this);"/>
<label for="img-input">
<img onError="this.onerror=null;this.src='images/nopicture.png';" style="cursor:pointer; border:1px; width:250px;" id="blah" src="#" />
</label>
<input type="submit" name="submit" value="Upload"/>
</form>

编辑: 这是javascript:

<script>
         function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#blah')
                    .attr('src', e.target.result)
                    .width(250)
                    .height(200);
            };

            reader.readAsDataURL(input.files[0]);
        }
    }
</script>

这里是文件uploadimage.php:

<?php
$file=$_FILES['image']['size'];
echo $file."</br>";
$file=$_FILES['image']['name'];
echo $file;
?>

0 个答案:

没有答案
相关问题