Java使用Ajax图片上传与修改

Java(腾讯云)[语音识别] 注册腾讯云 腾讯云官网:https://cloud.tencent.com/ 微信扫码注册后,以后扫码就可以登录了。 开通语音识别服务 第一步:在产品中找到 人工智能 → 语音识别。 第二步:点击立即使用。 开发文档 第一步:点击文档与资源,选择录音文件识别。 第二步:主要看 离线语音识别 和 识别结果回调 两部分。 栗子 转写方法: 在腾讯云的账号管理中,选择 访问管理 → 访问密钥 ... 阅读详情

图片上传

前言

开发工具:idea,MySQL
表单提交方式使用的是Ajax。

创建数据库和表

-- 创建数据库
CREATE DATABASE IF NOT EXISTS shoop DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- 创建一个文件上传的测试表
create table test_two(
  testId int auto_increment primary key,
  testPicture varchar(200)
)

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.springboot</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- spring boot mybatis依赖 -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.2.0</version>
        </dependency>
        <!-- 添加thymeleaf支持:类似于jsp的视图模板 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

application.properties

#数据源
spring.datasource.url=jdbc:mysql://localhost:3306/shoop?serverTimezone=Asia/Shanghai&useSSL=false&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

文件上传的辅助类(util)

@Configuration
public class UploadMapping implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //设置请求路径和文件物理路径映射关系
        registry.addResourceHandler("/upfile/**").addResourceLocations("file:e:/proj_img/");
    }
}

实体类(entity)

public class Test_two {
    private Integer testId;
    private String testPicture;
    //省略getter和setter方法   
    }

接口(mapper)

@Mapper
public interface PictureMapper {
    //图片上传
    public int insert(Test_two test_two);
}

myBatis配置文件(xml)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.springboot.mapper.PictureMapper">
    <insert id="insert" parameterType="com.springboot.entity.Test_two">
        insert into test_two(testPicture) values(#{testPicture})
    </insert>
</mapper>

业务层(service)

public interface IPictureService {
    //图片上传
    public int insert(Test_two test_two);
}

业务实现层(service.impl)

@Service
public class PictureServiceImpl implements IPictureService {
    @Resource
    PictureMapper mapper;
    @Override
    public int insert(Test_two test_two) {
        return mapper.insert(test_two);
    }
}

逻辑控制层(Controller)

@Controller
@RequestMapping("/Test")
public class PictureController {
    @Resource
    IPictureService service;
    
    //设置访问添加页面路径
    @RequestMapping("/select")
    public String select(){
        return "/admin/insert";
    }
    //图片上传
    @RequestMapping(value = "/insert")
    @ResponseBody
    public int insert(Test_two test_two, MultipartFile file) {
        String imgFile = null;
        //判断是否选择图片。如果用form表单提交用:if(file.isEmpty()){}
        if (file == null) {
            //没选为默认图片
            imgFile = "/img/mr.jpg";
        } else {
            //生成新的文件名
            String newFile = UUID.randomUUID() + "-" + file.getOriginalFilename();
            //使用新文件名构建文件对象
            File f = new File("e:/proj_img", newFile);
            //判断上级目录是否存在,不存在则创建
            if (!f.getParentFile().exists()) {
                f.mkdirs();
            }
            try {
                //将上传的图片保存到指定的位置
                file.transferTo(f);
                //记录上传文件的web访问路径
                imgFile = "/upfile/" + newFile;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //设置图片路径
        test_two.setTestPicture(imgFile);
        //保存对象到数据库
        int num = service.insert(test_two);
        if (num > 0) {
            return 1;
        } else {
            return 0;
        }
    }
}

HTML页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/jquery-1.8.3.min.js"></script>
</head>
<script type="text/javascript">
    //文件框选择文件时,图片标签自动切换图片
    function showImg() {
        //文件访问对象
        var f = new FileReader();
        f.onload = function (ev) {
            img.src=ev.target.result;
        }
        f.readAsDataURL(file.files[0]);
    }
</script>
<body>
<table>
    <tr>
        <td>商品图片</td>
        <td>
            <img src="/img/mr.jpg" width="80" height="100" id="img"/>
            <br/>
            <input type="file" name="file" id="file" onchange="showImg()"/>
        </td>
    </tr>
    <tr>
        <td>
            <input type="button" value="上传" id="but">
        </td>
    </tr>
</table>
</body>
<script>
$("#but").click(function() {
    //要知道file文件上传,并!=String类型的上传,所以我们要加上FormData()这个方法
    var files = new FormData();
    files.append('file', $('#file')[0].files[0]);
    $.ajax({
        type:"post",
        url:"/Test/insert",
        data:files,
        dataType:"json",
        processData: false,// 不处理数据
        contentType: false, // 不设置内容类型
        success:function(data) {
            if(data == 1){
                alert("上传成功");
            }else{
                alert("上传失败");
            }
        },
        error:function() {
            alert("上传时出现错误");
        }
    })
})
</script>
</html>

图片修改

修改需要先查询出所有图片,根据图片id查询单列的信息,最后进行修改。
需要的操作是:1.查询全部图片。2.查询单个图片。3.对图片进行修改然后刷新全部图片

接口(mapper)

@Mapper
public interface PictureMapper {
    //查询全部图片
    public List<Test_two> selectAll();
    //根据图片id查询单列数据
    public Test_two selectDan(Integer testId);
    //修改图片
    public int update(Test_two test_two);
}

myBatis配置文件(xml)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.springboot.mapper.PictureMapper">
    <select id="selectAll" resultType="com.springboot.entity.Test_two">
        select testId,testPicture from test_two
    </select>
    <select id="selectDan" resultType="com.springboot.entity.Test_two">
        select testId,testPicture from test_two where testId=#{testId}
    </select>
    <update id="update" parameterType="com.springboot.entity.Test_two">
        update test_two set testPicture=#{testPicture} where testId=#{testId}
    </update>
</mapper>

业务层(service)

public interface IPictureService {
    //查询全部图片
    public List<Test_two> selectAll();
    //根据图片id查询单列数据
    public Test_two selectDan(Integer testId);
    //修改图片
    public int update(Test_two test_two);
}

业务实现层(service.impl)

@Service
public class PictureServiceImpl implements IPictureService {
    @Resource
    PictureMapper mapper;

    //查询全部图片
    @Override
    public List<Test_two> selectAll() {
        return mapper.selectAll();
    }

    @Override
    public Test_two selectDan(Integer testId) {
        return mapper.selectDan(testId);
    }

    @Override
    public int update(Test_two test_two) {
        return mapper.update(test_two);
    }
}

逻辑控制层(Controller)

@Controller
@RequestMapping("/Test")
public class PictureController {
    @Resource
    IPictureService service;

    //查询全部图片
    @RequestMapping("/selectAll")
    public String selectAll(Model model){
        List<Test_two> testList = service.selectAll();
        model.addAttribute("testList",testList);
        return "/admin/select";
    }
    
    //根据图片id查询单列数据
    @RequestMapping("/selectDan")
    @ResponseBody
    public Object selectDan(Integer testId){
        Test_two testTwo = service.selectDan(testId);
         if(testTwo != null ){
             return testTwo;
         }else{
             return 0;
         }
    }
    @RequestMapping("/update")
    @ResponseBody
    public int update(Test_two test_two, MultipartFile file){
        String imgFile = null;
        //判断是否选择图片。如果用form表单提交用:if(!file.isEmpty()){}
        if(file != null){
            //生成新的文件名
            String newFile = UUID.randomUUID()+"-"+file.getOriginalFilename();
            //使用新文件名构建文件对象
            File f = new File("e:/proj_img",newFile);
            //判断上级目录是否存在,不存在则创建
            if(!f.getParentFile().exists()){
                f.mkdirs();
            }
            try {
                //将上传的图片保存到指定的位置
                file.transferTo(f);
                test_two.setTestPicture("/upfile/"+newFile);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //保存对象到数据库
        service.update(test_two);
        return 1;
    }
}

HTML页面

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.com">
<head>
    <meta charset="UTF-8">
    <title>查询全部图片</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
</head>
<script type="text/javascript">
    //文件框选择文件时,图片标签自动切换图片
    function showImg() {
        //文件访问对象
        var f = new FileReader();
        f.onload = function (ev) {
            img.src=ev.target.result;
        }
        f.readAsDataURL(file.files[0]);
    }
</script>
<body>
<table>
    <tr>
        <td>编号</td>
        <td>图片</td>
        <td>操作</td>
    </tr>
    <th:block th:each="test:${testList}">
    <tr>
        <td class="testId" th:text="${test.testId}"></td>
        <td>
            <img th:src="${test.testPicture}" width="80" height="60"/>
        </td>
        <td>
            <button onclick="select(this)" class="btn btn-default" data-toggle="modal" data-target="#myModal">修改</button>
        </td>
    </tr>
    </th:block>
</table>
<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    修改
                </h4>
            </div>
            <div class="modal-body">
                <input type="type" id="testId"/>
                <div>
                    请输入修改名称: <img src="" width="80" height="100" id="img"/>
                    <br/>
                    <input type="file" name="file" id="file" onchange="showImg()"/>
                    <input type="hidden" name="testPicture" id="testPicture"/>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" id="sub" class="btn btn-primary">
                    提交更改
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
<script>
    //查询
    function select(res) {
        var testId = $(res).parent().siblings(".testId").html();
        $.ajax({
            url:"/Test/selectDan",
            data:{
                testId:testId
            },
            success: function(data){
                if(data != 0){
                    $("#testId").val(data.testId);
                    //把图片路径赋给src
                    var picture= data.testPicture
                    document.getElementById("img").src = picture;
                    //默认图片路径,如果不修改图片,还是这个路径
                    $("#testPicture").val(data.testPicture);
                }
            },
            error:function (data) {
                alert("没有该商品信息");
            },
        });
    }
    //修改
    $("#sub").click(function() {
        //var testId = $("#testId").val();
        var files = new FormData();
        files.append('file', $('#file')[0].files[0]);
        files.append('testId',$("#testId").val());
        files.append('testPicture',$("#testPicture").val());
        $.ajax({
            type:"post",
            url:"/Test/update",
            data:files,
            dataType:"json",
            processData: false,// 不处理数据
            contentType: false, // 不设置内容类型
            success:function(data) {
                if(data == 1){
                    alert("修改成功");
                    //跳转到首页
                    window.location.href = 'http://localhost:8080/Test/selectAll';
                }else{
                    alert("修改失败");
                }
            },
            error:function() {
                alert("修改时出现错误");
            }
        })
    })
</script>
</html>

以上就是用Ajax进行图片上传与修改如果对各位有帮助,请点个赞。项目源码https://pan.baidu.com/s/1yt3brsDdrQL72Ii9itM73Q 提取码:l3we

java做的ajax异步上传 图片或文件的demo java做的ajax异步上传 图片或文件的demo 下载直接可以在eclipse的Tomact的里面运行!注意(配置自己的 jdk和tomcat!) 立即下载

相关推荐

java图片上传到服务器以及在服务器上图片修改删除

java图片上传到服务器以及在服务器上图片修改删除,可以从前端获取图片后端接收然后保存,还可以修改图片修改之前会删除原来的图片。

Java后台整合腾讯云语音识别

前提工作  1、仔细阅读腾讯云接口的详细介绍腾讯云接口网址https://cloud.tencent.com/document/product/1093/35691  2、接入步骤  生成自己的AppId、SecretId和SecretKey  3、创建一个Java项目在pom.xml配置文件中添加依赖 <!-- 注:这里只是示例版本号,请获取并替换为 最新的版本号 --> <dependency> <groupId&gt

微笑的博客 2420

VMware ESXi 7.0下Intel网卡SR-IOV配置实战:解决虚拟化网络延迟问题

本文详细介绍了在VMware ESXi 7.0环境下为Intel网卡配置SR-IOV(单根I/O虚拟化)的完整实战流程。通过硬件辅助直通技术,虚拟机可直接访问物理网卡资源,有效绕过虚拟化层瓶颈,从而显著降低网络延迟和CPU开销,适用于金融交易、实时计算等对性能敏感的场景。

embedding5hiker的博客 558

使用ajax完成图片上传

文件1:先说我们平时接触到的接口都是后台需要你给他传递几个参数,你就把参数对应的值。

ddf__的博客 1080

Ferry工单平台部署

ferry工单平台部署

运维求生之路 1901

Keystone变换(4)MATLAB仿真

关于Keystone变换三种方法(DFT-IFFT法、Sinc插值法和Chirp-Z法)的仿真

qq_45846079的博客 1571

语音识别java版demo

语音识别java版demo,三步完成账号的基本注册与认证

m0_59044499的博客 2751

【计算机图形学】Pov-Ray画的垃圾小车

效果: 代码: #include "colors.inc" #include "metals.inc" #include "glass.inc" //相机 //这个位置车子刚好落在草地上了 camera { location direction z*1.5 right x*image_width/image_height look_at

lishichengyan的博客 1753

java中AJAX上传图片

HTML <div class="col-sm-3" style="width: 120px;margin: 0 auto;"> <img src="" id="img" style="width: 100px;height: 100px;background-color: #00a7d0;margin: 0 auto"/> <...

Leon 1075

IC芯片验证 - 手把手教你搭建UVM验证环境

这是一个UVM的demo项目

howard789的博客 3万+

时间序列数据预测——15种时序大模型

本文综述了时间序列大模型(TSFM)的最新进展,系统介绍了11种主流模型(如TimeGPT、Lag-Llama、Moirai等)的架构特点、训练数据和创新点,并对比分析了它们在单变量/多变量预测、概率预测等功能上的差异。研究表明,基于"大规模预训练-微调/零样本"范式的TSFM在标准数据集(如M4、ETT)上展现出优于传统方法的性能,Time-MoE等模型更达到SOTA水平。但TSFM仍面临计算成本高、可解释性差等挑战,未来发展方向包括轻量级架构、多模态融合和可解释性增强。

m0_56592100的博客 4101

使用ajax上传图片和表单【ajax+Java后台】详解

最近有个需求,修改用户个人信息,效果如下; 流程说明: 用户点击修改后,弹出文件夹,选择图片并预览,点击确认修改后,上传图片,完成修改后给出提示“修改成功” HTML(这里用到了两个UI框架:layui和semantic ui,模板引擎使用的是:thymeleaf,以上只是对样式的影响,只有上传成功后的弹窗使用了layui) <link rel="sty...

weixin_42886104的博客 3567

ICLR 2025 | MambaPEFT: 探索针对Mamba的参数高效微调方法

通过利用海量数据构建大型模型,基于Transformer的模型生态系统已逐步确立。参数高效微调(PEFT)是一项至关重要的技术,它能以最低成本将这些模型应用于下游任务,同时实现高效的性能表现。最近,基于状态空间模型(SSM)的Mamba模型作为Transformer的潜在替代方案受到了广泛关注。尽管已经提出了许多基于Mamba的大规模模型,但如何高效地将预训练的Mamba模型应用于下游任务仍有待研究。在本文中,作者对适用于Mamba的PEFT方法展开了探索性分析。

小白学视觉 335

jsp+servlet实现一套简单的增删改查

功能简介 登录功能 ajax用户名失焦之后判断是否存在,cookie设置十天免登陆。 学生信息显示 图片上传以及图片删除功能未添加 删除功能 添加功能 修改功能 全选删除功能 代码实现 login.jsp登录界面: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% Str...

光头强的博客 4937

39、低功耗处理器性能评估与Cortex - M23/M33低功耗特性解析

本文深入解析了Cortex-M23和Cortex-M33处理器的低功耗特性及其性能评估方法。介绍了ULPMark、CoreMark、IoTMark-BLE和SecureMark-TLS等基准测试在能效评估中的应用,并详细阐述了处理器的睡眠模式、系统控制寄存器(SCR)配置、WFI/WFE指令、退出时睡眠、挂起时发送事件(SEVONPEND)以及唤醒中断控制器(WIC)等关键低功耗机制。结合状态保留技术,展示了如何通过芯片级设计大幅降低泄漏电流,实现高效能低功耗的物联网与嵌入式系统设计。

Pepper的专栏 132

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

计算机答辩常见问题汇总(二)

前后端的数据交互基本通过程序接口实现的,数据交互的过程可以简单理解为,前台想要。解到前台要获得什么数据,去数据库查询获取数据,然后将所需数据返回给前台,前台拿。是把测试对象看作一个黑。利用黑盒测试法进行动态测试时,需要测试软件产品的功能,不需测试软件产品的。验证码图片上的文字是随机生成的,系统中有一个接口,专门生成随机验证码,然后把。购物车是有了用户和图书之后并且在用户的登录,用户点击添加购物车就可以了,在。最新上架:每个化妆品上架之后,存入数据库,将最新的存入数据库的往前面排。

2401_84408400的博客 1330

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

java 上传的图片大小为0_Java上传图片到Ftp,包含上传后文件大小为0的问题和Properties配置文件的读取...

准备工作:需要使用coomos-net jar包。下载地址一、 上传图片到FTP,文件大小为0的问题,解决:将ftp模式修改为Passive模式就可以了。//将ftp模式修改为Passive模式ftpClient.enterLocalPassiveMode();1.使用.properties配置文件的形式定义相关常量。2.在工具类中导入配置文件private staticProperties ge...

weixin_35548251的博客 397

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

ShiroHttpServletRequest,文件上传时报错ClassCastException

第一个方法不适用我们这边,我们没用自己配置的bean,所以用了第二个方法试了一下,发现还是没解决问题,controller不能解决问题,思路还是回到了页面上来,html页面不会有问题,看一下JS发送请求的问题,仔细看了一下提交数据的接口,终于发现了问题,有图片上传的功能,提交请求数据方法直接使用。之前也做过很多次了,开发完成之后自测一下上传,图片上传之后,页面也有返显,但是在提交的时候报错了,看了一下日志,报了java.lang.ClassCastException: org.apache.

浅月流苏 1380

SpringBoot实现图片上传功能

SpringBoot 实现图片上传功能 SpringBoot 是为了简化Spring应用的创建、运行、测试、调试、部署等一系列问题而诞生的产物,自动装配的特性让我们可以更好的关注业务本事而不是外部的xml配置,我们只需遵循规范,引入相关的依赖就可以轻易搭建出一个web工程 说明 文件上传控件较多,本文以引用LayUI图片上传控件为例 页面上传插件使用Layui的图片上传控件,点击跳转 ...

Jerry 3417

java中使用fastDFS上传图片(前端ajax+后端ssm) --菜鸟小回

java中使用fastDFS上传图片(前端ajax+后端ssm) 准备:下载jar包 链接: fastDFS_client 提取码: 63m7 配置maven环境变量,与jdk配置方法相同。不再赘述:参考Windows中maven配置 找到你下载的jar包,直接在该路径下输入cmd回车 打包 //打包命令 mvn install:install-file -DgroupId=org....

菜鸟小回的博客 754

springboot项目实现图片上传到阿里云OSS

阿里云OSS文件/图片上传流程 服务端签名后直传并设置上传回调 客户端向服务端发起签名请求后,直传OSS然后OSS会回调对应的服务端回调接口,OSS回调完成后,应用服务器再返回结果给客户端。 特点:用户上传一个文件到OSS后,OSS会将上传结果返回给应用服务器,然后应用服务器会给OSS响应,然后OSS会将相关响应通知给客户端的用户。 Java代码: 导入阿里云的jar <dependenc...

allen_csdns的博客 6856

php图片预览ajax,使用ajax,结合jquery,php实现图片上传预览功能

大致逻辑:点击页面的file,上传图片到指定的php处理图片的文件,处理完成以后,将图片的连接地址返回,JS控制返回的数据,然后将图片动态的展示出来html代码 js代码$(document).ready(function() {var url = "fileupload.php";    //这里是你需要那个文件来处理图片$("#file").change(function() {//普通...

weixin_31297157的博客 262

java实现简单的图片上传_Summernote实现图片上传功能的简单方法

还是接着之前说过的最近在写一个BootStrap网页....然后要用富文本编辑器,随便搜了下就选了这货然后发现了很尴尬的问题...图片上传功能无效....然后各种搜索各种无果...最后怒翻Summernote官方文档总算解决了,总之写下解决过程后端部分就不提供代码了,满大街都是,这里假设后端拿到上传文件后返回文件的地址首先附上参考资料:Summernote官方开发文档简单说下Summernote的...

weixin_35011928的博客 159

java 前端jsp页面 通过ajax 上传多张图片 可从后台获取图片 并删除修改

<%@ page contentType=“text/html;charset=UTF-8” language=“java” %> <%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core” %> <%@ taglib prefix=“fmt” uri=“http://java.sun.com/jsp/jstl/fmt” %>

asfsdf23的博客 552

jquery fastdfs java_基于Springmvc使用jq异常图片上传至fastDFS 加回显

我们在开发的时候经常遇到一个场景,在修改一个对象信息的时候,会让图片上传上去,并加显。比如个人信息的头像上传,品牌信息的图片上传分析:1. 这种场景下我们经常会使用ajax异步传输的方式来实现这个功能。2. 我们这里使用的是基于springmvc开发的。所有需要给springmvc进行配置.(添加一个接收文件的配置文件,搭建环境这里不提)。3.当图片较多的时候,需要用到fastDFS专门设置一个图...

weixin_29602351的博客 120

ajax jq 图片上传请求头_jQuery+Ajax实现图片的预览和上传

jQuery+Ajax实现图片的预览和上传1、配置Spring-web.xml2、引用jQuery的插件ajaxFileUpload.js3、jsp代码点击图片即可修改确定修改4、js代码$(function() {//头像预览$("#headPic").click(function () {$("#upload").click(); //隐藏了input:file样式后,点击头像就可以本地上传$...

weixin_39968861的博客 387
上一篇: Ajax接收后端日期格式
下一篇: 引入js文件无法正常使用
与黑夜为伍
博客等级 码龄8年 19粉丝 80原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址