php+bootstrap fileinput去上传图片,返回失败,求助!
怪我咯
怪我咯 2017-04-11 09:57:34
0
0
882

正常提交的话,应该返回这个,如图
而下面的代码返回

<admintpl file="header" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml&...
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>

  
    <!--<input id="input-2" name="input2" type="file" class="file-loading" multiple data-preview-file-type="any">-->
      <input id="input-2" name="input2" type="file" class="file-loading" >
    <script type="text/javascript">
    
    var ctrlName = 'input-2';
    var control = $('#' + ctrlName); 

    
     control.fileinput({
        uploadUrl:"{:U('profile/upload')}",
        showCaption: false,
        showCancel:false,
        showUploadedThumbs:false,
        showClose:false,
        autoReplace:true,
        maxFileCount:5,
        overwriteInitial:true,
        showUploadedThumbs:false,
        language:'zh',
        initialPreview:"<img src='/back_t.jpg' class='file-preview-image' />",
        initialPreviewCount:1,
        initialPreviewShowDelete:false,
        layoutTemplates:{
             actions: '<p class="file-actions">\n' +
    '    <p class="file-footer-buttons">\n' +
    '    </p>\n' +
    '    <p class="file-upload-indicator" tabindex="-1" title="{indicatorTitle}">{indicator}</p>\n' +
    '    <p class="clearfix"></p>\n' +
    '</p>'
        }
    }).on('fileuploaded', function(event, data, previewId, index){ 
                  var str = JSON.stringify(data);  

alert(str);

    });
    
    
    </script>

</body>
</html>
namespace PartnerController;
use CommonControllerMemberbaseController;
class ProfileController extends MemberbaseController {

    public function upload(){  


    if ($_FILES['input2']["type"] == "image/png") {
    echo "{\"code\":0, \"message\":\"upload success!\"}";
} else {
    echo "{\"code\":-1, \"error\":\"Invalid file format\"}";
}

}
}

怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板