2012-04-22 67 views
0

我不想使用输入类型文件作为fileupload,而是使用可点击的div来调用正常的文件上传,就像输入一样。点击JQuery文件上传

instead of this 
<input type="file"/> 

I want this 
<div>Click to upload</div> 
and paste the file path in the div 
+0

_“并将文件路径粘贴到div中_这是什么意思? – gdoron 2012-04-22 03:41:48

+0

[这小提琴](http://jsfiddle.net/GMqK9/)可能会帮助你 – gdoron 2012-04-22 03:55:17

+0

是的,我真的不明白这个问题。也许他想传递输入文件名并用该路径替换div内容? – alt 2012-04-22 04:04:15

回答

1

想法:

当用户单击该DIV,呼吁文件输入点击事件,当它改变,插入HTML的DIV

在DIV

$('#magicdiv').click(function(){ 
$('#leupload').click(); 
    }); 

上传文件

$('#leupload').change(function(){ 
$('#magicdiv').html($(this).val()); 
});