GithubHelp home page GithubHelp logo

zzc1131554513 / wx_upfilephoto Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fancaixia/wx_upfilephoto

0.0 1.0 0.0 1.08 MB

小程序 + node 实现图片文件上传(附源码可预览上传结果)

JavaScript 100.00%

wx_upfilephoto's Introduction

wx_UploadFile 小程序 + node 实现图片文件上传(附源码可预览上传结果)

实现效果

本案例服务端使用node+express简单实现 ,不涉及mysql数据库存储,只为演示,主要偏向与前端页面

启动node服务后,上传结果可在node_test/upload 查看

(node启动后记得修改上传地址为本机IP)

  1. cd / node_test

  2. npm/cnpm install ( 安装依赖 )

  3. node app (启动服务)

本案例简单实现思路

data :{

upFilesBtn: true,     //上传数量 >= maxUploadLen  控制 添加按钮 显示隐藏
upFilesProgress: false,   //上传进度显示隐藏
maxUploadLen: 6,  //固定不变最多上传数量
chooseCount:6,    //跟随选择与删除图片事件变化   限制可选图片数量
upImgArr:null,     //存储选择图片

}

  1. 点击添加图片触发 wx.chooseImage ,选择完成后将已选文件列表存入数组 this.data. upImgArr

  2. wx.chooseImage 之前判断是否存在已选图片,存在的话重新计算可选数量( maxUploadLen - upImgArr.length)

  3. 删除已选图片后,更新数组upImgArr 重新计算可选数量( maxUploadLen - upImgArr.length)

  4. 点击上传按钮时判断upImgArr是否为空 不为空则继续上传

  5. 上传完成后清空upImgArr

wx_upfilephoto's People

Contributors

fancaixia avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.