如何获取上传文件的URL到脚本中 [英] How do I get URL of upload file into script

查看:224
本文介绍了如何获取上传文件的URL到脚本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上传完成后,我新上传的文件的URL为

Upon upload completion, my newly uploaded file has the URL of

    <div id="uploaded-file">

    <img src="http://path-to-my-file.jpg" />

    </div>

如何将上载文件的URL放入脚本?

How do I get the URL of that uploaded file into my script?

    <script>
    script stuff.use this.etc
    ('http://path-to-my-file.jpg')
    });
    </script>

在此先感谢您的帮助!

我用过:

    <script>
    var myurl = document.getElementById("uploaded-file").getElementsByTagName("img")[0].src;   

    </script>

然后替换硬编码的网址:

then replace the hardcoded url:

    Layer_3.mousedown(function() { this.animate({ fill:
    'url("http://farm5.staticflickr.com/4067/4584507098_b887327eae.jpg")' }, 600); });

    Layer_3.mousedown(function() { this.animate({ fill: 'url(' + myurl + ')' }, 600); });

这是JSFiddle

Here is JSFiddle

推荐答案

类似的东西

<script>
    var myurl = document.getElementById("uploaded-file").getElementsByTagName("img")[0].src;   
    alert(myurl);
</script>

这篇关于如何获取上传文件的URL到脚本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆