传照片

WCF实现上传图片功能

好久不见. 提交于 2020-01-16 22:02:13
初次学习实现WCF winform程序的通信,主要功能是实现图片的传输。 下面是实现步骤: 第一步: 首先建立一个类库项目TransferPicLib,导入wcf需要的引用System.ServiceModel,建立接口ITransferPicService,建立类文件TransferPicService实现ITransferPicService接口。 代码:ITransferPicService ITransferPicService using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.ServiceModel; using System.Text; using System.Threading.Tasks; namespace TransferPicLib { [ServiceContract] public interface ITransferPicService { [OperationContract]//操作契约 Stream GetPic(); [OperationContract] void SendPic(Stream transferPic); } } 代码:TransferPicService

TP5 base64图片上传

空扰寡人 提交于 2020-01-16 14:38:09
<?php /* * 上传方法 * */ namespace app \ common \ model ; use app \ common \ language \ Chinese ; use think \ Model ; class Uploads extends Model { /** * 上传图片 */ public function uploadImg ( $file ) { /*if(empty($file)) { return callback(0,'参数错误'); }*/ // 移动到框架应用根目录/public/uploads/ 目录下 $info = $file - > move ( ROOT_PATH . 'public' . DS . 'uploads' ) ; if ( $info ) { // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg $res = $info - > getSaveName ( ) ; $res = str_replace ( '\\' , '/' , $res ) ; $savename = "/uploads/" . $res ; return callback ( 1 , $savename ) ; } else { // 上传失败获取错误信息 return

贴段上传图片代码,截取缩略图

北慕城南 提交于 2020-01-16 05:11:37
[PS:原创,如转载,请注明转载出处,谢谢] 这段代码杂用?有啥用?能干什么? 最近在做一个图片网,你说能干嘛用呢??呵呵。。。 一张高清图,最少都是一MB以上的,看了这个之后,你还在用原来的,只保存一张图片??? 那你显示列表页的时候,不卡死了才怪了,一个页面显示60张图片,一张图片来个不多,1MB,整个列表下来是60MB。。。老大,强悍。。。牛B哇。。。嘿嘿 搞啥?不搞啥,切出来后,在搞,显示缩略图,弄成几十K的大小,显示一张比例为800*600的图,用到详细页面去,在搞个原图,用来点击查看原图用,这样就不用当心了吧?速度自然就上去了 View Code using System.IO;using System.Drawing;/// <summary> /// 图片上传 /// </summary> /// <param name="uname">用户名,用于生成图片名称</param> /// <param name="file">HttpPostedFile</param> /// <returns>图片路径</returns> public string[] ImgUpLoad(string uname, HttpPostedFile file) { string[] returnImg = new string[3]; int intThumbWidth = 160;

Python的两种上传图片方式

好久不见. 提交于 2020-01-16 02:36:31
Python的两种上传图片方式 1.上传至七牛云服务器 2.上传至自己服务器 1.上传至七牛云服务器 access_key = '替换成你的' # 个人中心->密匙管理->SK secret_key = '替换成你的' # 七牛空间名 bucket_name = '替换成你的' #临时域名 url = '替换成你的' q = qiniu . Auth ( access_key , secret_key ) def qiniu_upload ( key , localfile ) : token = q . upload_token ( bucket_name , key , 3600 ) ret , info = qiniu . put_file ( token , key , localfile ) if ret : return 'http://{0}/{1}' . format ( url , ret [ 'key' ] ) else : raise Exception ( '上传失败,请重试' ) @csrf_exempt def upload_qiniu ( request ) : """ @api {POST} /upload_qiniu/ [上传图片至七牛] * @apiVersion 0.0.1 * @apiGroup upload @apiParamExample

微信小程序图片上传

邮差的信 提交于 2020-01-15 08:53:44
uploadImage : function (){   wx.chooseImage({      count: 9, // 默认9      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有      success: function (res) {      // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片      var tempFilePaths = res.tempFilePaths      console.log(tempFilePaths)      for (var i = 0; i < tempFilePaths.length; i++){       wx.uploadFile({         url: http + 'api/Image/imageupload',         filePath: tempFilePaths[i], //待上传的图片,由 chooseImage获得         name: 'file',         formData: {           'user':

阿里云OSS存储之图片上传逻辑的编写

时光毁灭记忆、已成空白 提交于 2020-01-13 13:42:34
package cn.learn.haoke.dubbo.api.controller; import cn.learn.haoke.dubbo.api.service.PicUploadService; import cn.learn.haoke.dubbo.api.vo.PicUploadResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; @RequestMapping("pic/upload")

html 实现 上传图片到页面,直接展示,不需要上传到服务器目录(实现图片预览功能)

早过忘川 提交于 2020-01-11 02:01:34
html 实现 上传图片到页面,直接展示,不需要上传到服务器目录(实现图片预览功能) <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <style type="text/css"> #preview { display: inline-block; width: 2.56rem; height: 2.56rem; position: relative; background-repeat: no-repeat; background-size: cover; } #file { width: 100%; height: 100%; opacity: 0; position: absolute; left: 0; top: 0; cursor: pointer; z-index: 5; } </style> </head> <body> <div id="preview" style="width:200px;heigth:200px;border:1px solid"> <input

文件图片上传目录 禁止执行php

霸气de小男生 提交于 2020-01-10 17:52:11
apache配置上传目录禁止运行php的方法 导读: 禁止上传目录运行php等可执行文件可以从一定程度上增加网站的安全性, 禁止上传目录运行php的方法可以用.htaccess文件, 也可以直接在apache服务器上修改配置文件. 注意:这里需要防范的文件有三种 1. 正常php文件 a.php 2. php扩展名有大小写 a.pHp a.PHP a.Php 3. 双重扩展名文件 a.php.a a.php.xml 通常只考虑到第一种情况,渗透攻击常使用2和3 修改apache配置文件httpd.conf,防范三种情况 <Directory /var/www/uploads> <FilesMatch "\.(?i:php|php3|php4|php5)"> Order allow,deny Deny from all </FilesMatch> </Directory> 可以用.htaccess文件来限制上传目录运行php .htaccess方法A (未测试) 新建一个.htaccess文件,拷贝下面的内容, 上传到要禁止运行php的文件夹内 <FilesMatch "\.(?i:php|php3|php4|php5)"> Order allow,deny Deny from all </FilesMatch> 这种方式可以禁止执行php,但是会下载文件 <Directory "

小程序腾讯云上传图片

我的梦境 提交于 2020-01-10 17:07:34
腾讯云上传图片 需要下载cos-wx-sdk-v5并引入 命令yarn install cos-wx-sdk-v5 import COS from "cos-wx-sdk-v5" ; < img v - if = "imgUrl" : src = "imgUrl" alt / > < img v - else : src = "imagePath" @click = "selectPhoto" mode = "aspectFill" / > // 上传图片 selectPhoto ( ) { var that = this ; var cos = new COS ( { getAuthorization : function ( params , callback ) { //获取签名 必填参数 // 方法二(适用于前端调试) var authorization = COS . getAuthorization ( { SecretId : "AKIDOmvpbBscR1ax58BVr1xqVvGRN3TeurgH" , SecretKey : "Zu0pQuFKBm8E6kIcgcJlwrX9YiiSxCCx" , // stsToken: that.sign.credentials.sessionToken, Method : params . Method , Key :

【c#】winform 上传图片

≯℡__Kan透↙ 提交于 2020-01-10 03:47:45
1、拖拽上传图片 1.1、后台代码中修改窗体属性,添加 AllowDrop = true 1.2、给窗体添加拖拽事件,在事件列表找到拖拽 双击即可: 在 DragDrop 生成的方法中添加代码如下: private void Form1_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } } 在 DragEnter 方法中添加代码如下: private void Form1_DragEnter(object sender, DragEventArgs e) { //判断 string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; string file = files[0]; if (!file.ToLower().EndsWith(".png") && !file.ToLower().EndsWith(".jpg")) { MessageBox.Show("需要图片文件!"); return; } /