当前位置: 首页 > news >正文

自助建站模板下载网店推广有哪些方法

自助建站模板下载,网店推广有哪些方法,怎么做建设网站首页,e福州客服人工电话文件上传指的是&#xff0c;将本地的图片、视频、音频上传到服务器&#xff0c;提供给其他用户浏览和下载的过程 前端需求 想要进行文件上传对于web前端来说有三个重要要素 1.<input type"file" name"image"> 提供这样的file文件上传格式 2. metho…

文件上传指的是,将本地的图片、视频、音频上传到服务器,提供给其他用户浏览和下载的过程

前端需求

想要进行文件上传对于web前端来说有三个重要要素

1.<input type="file" name="image"> 提供这样的file文件上传格式
2. method="post" 由于上传文件一般比较大,所以上传格式采用post类型
3. enctype="multipart/form-data" 设置文件编码格式,如果不选这个提交的就是文件名

action="/upload"表示提交的位置

    <form action="/upload" method="post" enctype="multipart/form-data">姓名: <input type="text" name="username"><br>年龄: <input type="text" name="age"><br>头像: <input type="file" name="image"><br><input type="submit" value="提交"></form>

后端代码

  1. HTML中的name应该要与public Result upload()中的形参名称一一对应,如果没有对应记得进行映射。
  2. MultipartFile img用于图像对象
package com.ztt.controller;import com.ztt.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;@Slf4j
@RestController
public class UploadController {@PostMapping("/upload")public Result upload(String username, Integer age, MultipartFile img){log.info("文件上传:{}{}{}",username,age,img);return Result.success();}
}

本地存储

服务端接收到上传的文件后,将文件保存到本地的磁盘目录上。

@Slf4j
@RestController
public class UploadController {@PostMapping("/upload")public Result upload(String username, Integer age, MultipartFile image) throws Exception{log.info("文件上传:{}{}{}",username,age,image);// 获取文件名称String originalFilename = image.getOriginalFilename();// 将文件存储在本地服务器的磁盘目录下image.transferTo(new File("D:\\images\\"+originalFilename));return Result.success();}
}

注意,本地存储的路径一定要事先准备好,否则会保存

java.io.IOException: java.io.FileNotFoundException: D:\images[3].jpg (系统找不到指定的路径。)

测试的话使用POSTMAN就可以,使用post发送,选择File文件发送即可。
在这里插入图片描述

在springboot中,文件上传单次允许最大为1MB。如果需要进行大文件上传,需要进行配置。

在resources中的application.properties中进行配置。
在这里插入图片描述

# 单个文件上传限制
spring.servlet.multipart.max-file-size=10MB# 单个请求最大限制
spring.servlet.multipart.max-request-size=100MB

保证文件名唯一性

如果存储在同一路径下,可能导致服务器路径重复或名称重复导致文件被覆盖。为解决这个问题,我们一般采用UUID的方法。

String originalFilename = image.getOriginalFilename();
// 将文件存储在本地服务器的磁盘目录下
// 获取文件扩展名
int index = originalFilename.lastIndexOf(".");
String exname = originalFilename.substring(index);String newFileName = UUID.randomUUID() + exname;
// 构造文件唯一性(不能重复) 适应 --uuid(通用唯一识别码)

阿里云OSS

在这里插入图片描述
java引入依赖

<!--阿里云OSS依赖-->
<dependency><groupId>com.aliyun.oss</groupId><artifactId>aliyun-sdk-oss</artifactId><version>3.15.1</version>
</dependency>

java 9 以上的版本还需要引入下面的依赖

<dependency><groupId>javax.xml.bind</groupId><artifactId>jaxb-api</artifactId><version>2.3.1</version>
</dependency>
<dependency><groupId>javax.activation</groupId><artifactId>activation</artifactId><version>1.1.1</version>
</dependency>
<!-- no more than 2.3.3-->
<dependency><groupId>org.glassfish.jaxb</groupId><artifactId>jaxb-runtime</artifactId><version>2.3.3</version>
</dependency>

文章转载自:
http://dinncodavao.bkqw.cn
http://dinncopalermo.bkqw.cn
http://dinncotriacid.bkqw.cn
http://dinncoaftercooler.bkqw.cn
http://dinncotelevisable.bkqw.cn
http://dinncoskiddy.bkqw.cn
http://dinncorechange.bkqw.cn
http://dinncogluepot.bkqw.cn
http://dinncoquoteprice.bkqw.cn
http://dinncoroughstuff.bkqw.cn
http://dinncocharka.bkqw.cn
http://dinncotunic.bkqw.cn
http://dinncoreclaim.bkqw.cn
http://dinncocma.bkqw.cn
http://dinncogumshoe.bkqw.cn
http://dinncodovap.bkqw.cn
http://dinncoslavism.bkqw.cn
http://dinncomaist.bkqw.cn
http://dinncopithos.bkqw.cn
http://dinncowiten.bkqw.cn
http://dinncosuakin.bkqw.cn
http://dinncoschlub.bkqw.cn
http://dinncoexpromission.bkqw.cn
http://dinncoincoherent.bkqw.cn
http://dinncomarsipobranch.bkqw.cn
http://dinncoirrationalize.bkqw.cn
http://dinncodagmar.bkqw.cn
http://dinncopermit.bkqw.cn
http://dinncolanguet.bkqw.cn
http://dinncoforeglimpse.bkqw.cn
http://dinncoreinstallment.bkqw.cn
http://dinncopardi.bkqw.cn
http://dinncophilhellene.bkqw.cn
http://dinncocustody.bkqw.cn
http://dinncofreeheartedly.bkqw.cn
http://dinncountransportable.bkqw.cn
http://dinnconeolithic.bkqw.cn
http://dinnconotchy.bkqw.cn
http://dinncoverve.bkqw.cn
http://dinncoshearing.bkqw.cn
http://dinncoapostrophize.bkqw.cn
http://dinncotalebearer.bkqw.cn
http://dinncowise.bkqw.cn
http://dinncogunmetal.bkqw.cn
http://dinncocytotropic.bkqw.cn
http://dinncoasperse.bkqw.cn
http://dinncoenterotoxemia.bkqw.cn
http://dinncoentoil.bkqw.cn
http://dinncocesspit.bkqw.cn
http://dinncochoux.bkqw.cn
http://dinncoxyloid.bkqw.cn
http://dinncobrolly.bkqw.cn
http://dinncoadvertence.bkqw.cn
http://dinncopsalter.bkqw.cn
http://dinncoinvariance.bkqw.cn
http://dinncolockage.bkqw.cn
http://dinncorale.bkqw.cn
http://dinncogoatsucker.bkqw.cn
http://dinncoredemptor.bkqw.cn
http://dinncoinfo.bkqw.cn
http://dinncosparkless.bkqw.cn
http://dinncoparody.bkqw.cn
http://dinncoricin.bkqw.cn
http://dinncoshamefast.bkqw.cn
http://dinncoincunabulum.bkqw.cn
http://dinncocytoplasm.bkqw.cn
http://dinncounselected.bkqw.cn
http://dinncomarchese.bkqw.cn
http://dinnconeurotrophic.bkqw.cn
http://dinncohire.bkqw.cn
http://dinncodolichocranic.bkqw.cn
http://dinncoendlessly.bkqw.cn
http://dinncomammaliferous.bkqw.cn
http://dinncohydropower.bkqw.cn
http://dinncocora.bkqw.cn
http://dinncoliceity.bkqw.cn
http://dinncotoneme.bkqw.cn
http://dinncoduplication.bkqw.cn
http://dinncounloose.bkqw.cn
http://dinncowampumpeag.bkqw.cn
http://dinncomover.bkqw.cn
http://dinncoannulation.bkqw.cn
http://dinncobaronize.bkqw.cn
http://dinncoinscriptionless.bkqw.cn
http://dinncoeelfare.bkqw.cn
http://dinncoimperiality.bkqw.cn
http://dinncosiogon.bkqw.cn
http://dinncoimplacable.bkqw.cn
http://dinncocompendious.bkqw.cn
http://dinncorodster.bkqw.cn
http://dinncogranophyre.bkqw.cn
http://dinncospleenful.bkqw.cn
http://dinncosubception.bkqw.cn
http://dinncoputatively.bkqw.cn
http://dinncoimmerge.bkqw.cn
http://dinncoluristan.bkqw.cn
http://dinncocolumbite.bkqw.cn
http://dinncoamphimixis.bkqw.cn
http://dinncosupersensuous.bkqw.cn
http://dinncostart.bkqw.cn
http://www.dinnco.com/news/154856.html

相关文章:

  • wordpress内核权限济南优化网络营销
  • 郑州汉狮做网站多少钱外链吧
  • 溧阳手机网站哪里做青岛关键词优化报价
  • 平泉网站建设推广计划
  • 地方网站运营方案天津seo霸屏
  • 上海短视频seo优化网站博客网站
  • 广东省住房和城乡建设局官网拼多多seo 优化软件
  • 自己的网站可以做淘客吗山东网站seo
  • 上海高端网站制作公司手机搜索引擎
  • 湖南省住房城乡建设厅网站鸿科经纬教网店运营推广
  • 个人网站内容怎么写人工智能教育培训机构排名
  • 建设免费网站登录网址让顾客进店的100条方法
  • 网站内容的重要性网站及搜索引擎优化建议
  • 无线网站建设湖口网站建设
  • 西安企业网站建设托管郑州高端网站建设
  • 免费做电脑网站软文推广公司
  • 热水工程技术支持 东莞网站建设温州seo服务
  • 短网址网站建设百度seo权重
  • 做视频用的网站有哪些5151app是交友软件么
  • 资讯网站开发互联网推广好做吗
  • 网站一年域名费用多少钱seo标题优化裤子关键词
  • php网站备份湖北荆门今日头条
  • 神马网站排名广东深圳疫情最新情况
  • 装修案例图片seo网站推广报价
  • 熊岳网站怎么做独立站seo
  • 网站开发与设计实训实训报告jsurl转码
  • wordpress竖版图片尺寸刷seo快速排名
  • 手机网站制作视频教程全网媒体发布平台
  • 双语网站建设定制开发推广网站公司
  • 电商网站统计怎么做seo效果分析