doujia4759 2016-09-22 04:46
浏览 51

如何知道大小和文件扩展名?

On the page have a link to the file:

<a href="file.doc">File</a>

Next to the link should automatically show the extension and file size. Example: File (DOC, 15 KB)

How to do it?

I found this documentation:

How to have jQuery restrict file types on upload?

Find size of file behind download link with jQuery

but don't know how to unite them and show

UPD okay, how to know the file extension?

  • 写回答

2条回答 默认 最新

  • douzhiji2020 2016-09-22 04:50
    关注

    If you can determine that information ahead of time, you can use data attributes to tag the link and then display the extra content via CSS :after selector and content: attr(data-size), etc.

    If you can't, I think the links would need to be absolute file system links and you could do an Ajax HEAD request on the path to grab the content-length header, do some basic math, and add the relevant information.

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算