Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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
未发布html+;js+;php_Php_Jquery_Html_File_Posting - Fatal编程技术网

未发布html+;js+;php

未发布html+;js+;php,php,jquery,html,file,posting,Php,Jquery,Html,File,Posting,我的HTML中有一个字段,用于发送文件。。当用户选择一个图像时,他们会得到一个他们将要上传的图像预览(js)。激活此预览脚本后,$\u文件post不会发送任何数据(php通过var\u转储($\u文件)验证) 以下是JS: function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e

我的HTML中有一个字段,用于发送文件。。当用户选择一个图像时,他们会得到一个他们将要上传的图像预览(js)。激活此预览脚本后,
$\u文件
post不会发送任何数据(php通过
var\u转储($\u文件)
验证)

以下是JS:

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

    reader.onload = function (e) {
        $('#preview')
            .attr('src', e.target.result)
            .css('display', 'block');
        $('#upload').html('<i class="icon-upload"></i> <input type="file" onchange="readURL(this);" size="1" name="foto" class="input-file" />Cambiar im&aacute;gen')
    };

    reader.readAsDataURL(input.files[0]); // <- If I delete this line it posts correctly but dosen't preview the image.
}
函数readURL(输入){
if(input.files&&input.files[0]){
var reader=new FileReader();
reader.onload=函数(e){
$(“#预览”)
.attr('src',e.target.result)
.css(“显示”、“块”);
$('#upload').html('Cambiar imá;gen')
};

reader.readAsDataURL(input.files[0]);//实际上,我认为这是HTML5的特性。它肯定会在上运行


Internet Explorer=10+、Firefox:10+、Chrome:13+、Opera:12+、Safari:partial

也许是个愚蠢的问题,但您使用的是哪种浏览器?我相信目前只有FileReader()