weixin_33695082 2014-08-13 03:43 采纳率: 0%
浏览 38

jQuery,Ajax发布文件上传

I need to post the file upload to the current page by jquery, then upload the file , and then insert file upload, but the code not work... jquery can't post the file upload to the form:

 <form class="form-inline" role="form" id="form" enctype="multipart/form-data">
 <td colspan="3"><input type="file" name="pic_map" id="pic_map"></td>
 </form>

and this is javascript:

 $('#save').click(function (e) {
    $.post(
            "index.php?page=form1_sub1&pguid=<?php echo $pguid;?>",
            $("#form").serialize()
        )
        .done(function (data) {
            console.log(data);
            window.open('index.php?page=form1_sub2&pguid=<?php echo $pguid;?>', '_self');
        })
        .fail(function () {
            alert('<?php echo _CONNECTION_ERROR; ?>');
        });
});

and this is php code:

 $files = $_FILES['pic_map']['name'];
if(!$db->upload($_FILES['pic_map'], 'uploads/maps/'.$files)) {
    exit('file error');
}
  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 Android URL如何转成视频/音频,可行吗?
      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题