如何在MVC中的web api中将图像上传到Web服务器 [英] How to upload images to web server in web api in MVC

查看:88
本文介绍了如何在MVC中的web api中将图像上传到Web服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习asp.net mvc中的web api阶段。



i希望通过发布数据使用WEB API将图像上传到网络服务器。

i希望将Web服务器的路径转换为数据库,并将转换后的图像转换为base64,但它需要花费太多冗长的字符串。如何上传这个并获得web api中的短片图像路径。

请帮助



我尝试过:



i试过这个请帮我用web api获取短片图像路径



HI i am at learning phase of web api in asp.net mvc.

i want to upload image to web server online using WEB API by posting data.
i want to take that path of web server to the database with the converted image to base64 but it tooks too much lengthy string. how to upload this and get short length image path in web api.
please help

What I have tried:

i have tried this please help me to get the short length image path using web api

string fn = string.Empty;
var element2 = image.Split(',')[1];
fn = username + "_" + labTestId + ".jpg";
MemoryStream ms = new MemoryStream(Convert.FromBase64String(element2));
string folder_name = "lab-orders";
folder_name = folder_name.ToLower();
string SaveLocation = ServerConfig.BlobPath + folder_name + "/" + fn;
BlobUploader.UploadTo(folder_name, fn, ms);

LabTestNames labtstnames = new LabTestNames();
labtstnames.ImagePath = SaveLocation;

推荐答案

使用Web API 2.0将图像上传到服务器 [ ^ ]


这篇关于如何在MVC中的web api中将图像上传到Web服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆