如何在上传之前获取文件的路径? [英] How to get the path of a file before its uploaded?
本文介绍了如何在上传之前获取文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个上传框...
I have an upload box...
<form action="upload_file.php" method="post" enctype="multipart/form-data"><BR>
<label for="file">Filename:</label><BR>
<input type="file" name="file" id="file" /><BR>
<input type="submit" name="submit" value="Submit" />
</form>
现在,当我单击浏览并获取要上传的图像并单击它时,它将在随附的文本框中显示文件的路径.现在,我想获取该路径并将其插入到<img>
标记中,以便在上载之前显示以获取预览.
Now when I click browse and get the Image I want to upload and click it, it shows the path of the file into the text box that comes with. Now I want to get that path and insert it into a <img>
tag so It will show to get a preview before I upload.
推荐答案
尝试一下:
<script>
function lalala(str){
alert(str);
}
</script>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input type="file" name="file" id="file" onchange="lalala(this.value);" />
</form>
它在IE8中为我工作,它为我提供了完整的路径,但在Firefox和chrome中仅打印文件名:(
It worked for me in IE8 it gives me the complete path but in firefox and chrome is just prints the file name :(
这篇关于如何在上传之前获取文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文