前端页面同时上传文本和文件到数据库(inpt text和input file)

本文介绍了如何使用SpringBoot和jQuery实现同时上传文本和文件到数据库。前端利用FormData封装表单数据,后台通过MultipartHttpServletRequest处理文件和文本,将文件存储为Blob并保存路径到数据库,Base64编码的图片可以直接在前端展示。
摘要由CSDN通过智能技术生成

最近遇到了这么一个情况,需要同时上传文本和文件到数据库。

我是用springboot + jquery实现的 。

前端代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>文件上传</title>

</head>

<body>
<form id="uploadForm" method="post" enctype="multipart/form-data">
    <input type="text" name="info">
    <input type="text" name="info">
    <input type="file" name="file">
    <input type="file" name="file">
</form>
<button id="uploadButton">存入数据库</button>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
        $(document).ready(function () {
            $("#uploadButton").click(function () {
                alert("测试");
                var 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值