【问题标题】:jQuery-File-Upload- show selected file physical pathjQuery-File-Upload- 显示选择的文件物理路径
【发布时间】:2023-04-04 07:50:01
【问题描述】:

我正在使用这个plug 来上传文件

我的问题是,当我点击时

<input type="file" class="upload" id="imgAuthorImageUpload" accept="image/gif, image/jpeg,image/jpg,image/bmp,image/pjpeg,image/png" />

imgAuthorImageUpload - 弹出窗口将从探索中打开,它会让您选择要上传的文件

一旦开始上传,我想在页面上显示该文件位置,

例如,

如果我从 d 驱动器图片文件夹中选择了 animal.png:那么我想显示这样的内容

D:/Pictures/animal.png

我这样写的代码:

$("#imgAuthorImageUpload").fileupload({
        url: '/picture/DashBoard/pictureUpload.ashx',
        dataType: 'json',
        cache: false,
        async: true,
    }).on('fileuploadadd', function (e, data) {
        e.preventDefault();
    }).on('fileuploaddone', function (e, data) {
        alert("upload done");
        e.preventDefault();
    }).on('fileuploadprogress', function (e, data) {
        var percentVal = '0%';
        var percentVal = parseInt(data.loaded / data.total * 100, 10);
        $('.bar').css(
                'width',
                percentVal + '%'
            );
        $('.percent').html(percentVal + '%');
    }).on('fileuploadcomplete', function (e, data) {
        alert("Upload complete");
    });

【问题讨论】:

标签: javascript jquery html file-upload


【解决方案1】:

出于安全原因,浏览器不允许这样做。

这里提供了一个很好的解释:Full path from file input using jQuery

【讨论】:

  • 他为什么得到-1?他给出了完美的答案
  • +1 我同意 Pratik,不必要的反对。出于安全原因,您不会获得完整路径 - 但您可以获得文件名,请参阅this
猜你喜欢
  • 2014-06-14
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-20
  • 1970-01-01
相关资源
最近更新 更多