如果这样写的话就可以成功上传处理图片
<script type="text/javascript">
$(document).ready(function(){
$('#the').submit(function() {
var options = {
//target:'#d', //后台将把传递过来的值赋给该元素
url:'upload.php', //提交给哪个执行
type:'POST',
success: function(){ alert("yes");} //显示操作提示
};
$('#the').ajaxSubmit(options);
return false; //为了不刷新页面,返回false,反正都已经在后台执行完了,没事!
});
});
</script><form method='post' id='the' enctype="multipart/form-data" >
<input id="file1" name="file" type="file" />
<input type="submit" value="submit"/>
</form>而这样写就不行 区别就是 第一种是通过按钮触发提交 第二种是通过file域onchange事件触发提交
<script type="text/javascript">
$(document).ready(function(){
$('#the').submit(function() {
var options = {
//target:'#d', //后台将把传递过来的值赋给该元素
url:'upload.php', //提交给哪个执行
type:'POST',
success: function(){ alert("yes");} //显示操作提示
};
$('#the').ajaxSubmit(options);
return false; //为了不刷新页面,返回false,反正都已经在后台执行完了,没事!
});
});
</script><form method='post' id='the' enctype="multipart/form-data" >
<input id="file1" name="file" type="file" onchange='document.getElementById("the").submit()'/>
</form>
请问这怎么弄
<script type="text/javascript">
$(document).ready(function(){
$('#the').submit(function() {
var options = {
//target:'#d', //后台将把传递过来的值赋给该元素
url:'upload.php', //提交给哪个执行
type:'POST',
success: function(){ alert("yes");} //显示操作提示
};
$('#the').ajaxSubmit(options);
return false; //为了不刷新页面,返回false,反正都已经在后台执行完了,没事!
});
});
</script><form method='post' id='the' enctype="multipart/form-data" >
<input id="file1" name="file" type="file" />
<input type="submit" value="submit"/>
</form>而这样写就不行 区别就是 第一种是通过按钮触发提交 第二种是通过file域onchange事件触发提交
<script type="text/javascript">
$(document).ready(function(){
$('#the').submit(function() {
var options = {
//target:'#d', //后台将把传递过来的值赋给该元素
url:'upload.php', //提交给哪个执行
type:'POST',
success: function(){ alert("yes");} //显示操作提示
};
$('#the').ajaxSubmit(options);
return false; //为了不刷新页面,返回false,反正都已经在后台执行完了,没事!
});
});
</script><form method='post' id='the' enctype="multipart/form-data" >
<input id="file1" name="file" type="file" onchange='document.getElementById("the").submit()'/>
</form>
请问这怎么弄
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货