douji3426 2014-08-29 11:30
浏览 383
已采纳

Jasny BootStrap,输入类型的设置值=“file”

im using Jasny Bootstrap library

http://jasny.github.io/bootstrap/

im using the file input field.

                <div class="form-group">
                    <label class="control-label col-lg-2">Site Logo</label>
                    <div class="col-lg-10">
                        <div class="fileinput fileinput-new input-group" data-provides="fileinput" id="fileInputSiteLogo">
                            <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                            <span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new">Select file</span><span class="fileinput-exists">Change</span><input type="file" name="siteLogo"></span>
                            <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                        </div>
                    </div>
                </div><!-- /.form-group -->

Problem is i want to set the value in to that.

for normal TextBox in jQuery i know it is

$('#inputselector').val($phpVariable);

and in HTML it is

value = "<?php echo $phpVariable ?>"

i have data coming from database and i want to set the existing value to this file input field.

Please tell for both HTML and jQuery if possible.

  • 写回答

1条回答 默认 最新

  • douli1854 2014-08-29 13:05
    关注

    The file name is displayed in .fileinput-filename.

    <span class="fileinput-filename"><?php echo $phpVariable ?></span>
    

    or using JavaScript

    var filename = "<?php echo $phpVariable ?>";
    $('#myFileUpload .fileinput-filename').text(filename);
    

    This example doesn't do proper escaping.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题