TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kalyani Shevale
NA
3.2k
705.1k
how to get image from andriod web service to server in mvc
Nov 12 2018 10:52 PM
I have created this code for getting an image from the Android side then this add-in folder then insert to database.
//Web Service
[HttpPost]
public
ActionResult UpdateUser(HttpPostedFileBase UploadLogo,
string
UserId)
{
if
(UserId!=
null
&& UploadLogo!=
null
)
{
#region
var fileName = String.Empty;
var file =
string
.Empty;
if
(UploadLogo !=
null
)
{
string
strPath = Server.MapPath(
"/UserImage"
);
if
(!System.IO.Directory.Exists(strPath))
{ System.IO.Directory.CreateDirectory(strPath);}
//HttpPostedFileBase file1 = null;
UploadLogo = Request.Files[0];
fileName = Path.GetFileName(UploadLogo.FileName);
System.IO.DirectoryInfo dir =
new
System.IO.DirectoryInfo(strPath);
int
count = dir.GetFiles().Length;
fileName = fileName.Substring(0, fileName.IndexOf(
'.'
)) +
"_"
+ DateTime.Now.Millisecond +
"-"
+ DateTime.Now.Second +
"-"
+ DateTime.Now.Minute +
"-"
+ DateTime.Now.Hour +
"."
+ fileName.Substring(fileName.IndexOf(
'.'
) + 1);
var path = Path.Combine(strPath, fileName);
UploadLogo.SaveAs(path);
file = fileName;
}
#endregion
ViewModel.User.User user =
new
BussinessLogic.User.User(
new
UserRepository(
new
CRMContext())).EditUser(
new
ViewModel.User.User()
{
UploadLogo=file,
id=Convert.ToInt32(UserId)
});
if
(user.ErrorMessage.Equals(
"Updated"
))
{
return
Json(
new
{message =
"Image SuccessFully Updated"
}, JsonRequestBehavior.AllowGet);
}
else
{
return
Json(
new
{ message =
"Image Not Updated"
}, JsonRequestBehavior.AllowGet);
}
}
else
{
return
Json(
new
{ message =
"Please Select Image"
}, JsonRequestBehavior.AllowGet);
}
}
from android, image is get in string format .how to get this image then how to convert this image in image format.
from Andriod side image string:
"
iVBORw0KGgoAAAANSUhEUgAAAHMAAADMCAIAAADPvQsRAAAAA3NCSVQFBgUzC42AAAAgAElEQVR4
nNV9y6olubbdyHW0LlOwL+xtqlHVOwl2o8CdA/4Cf4b/wv/hf3TzunFwJlSBJiyRuDHfkmLtnfW6
1yJrV6wIhR5D861HfHp9JQCYAICGSFP/zwABDCaQ/ARA2PIvadpTufDy44IZAEgKtyLZXiRYvVYi
XdTEBOJysWaQWlAqukqcqo60/HySrCJ8ohey15hAPBkNDiLJn2sEeSrimloMCcBc8KI0Ljte0ef0
mGueZ/35WM+vkZ2gdlnIqfzLoiRz8x9oBIBa5KYJhTWBJU+4EIK0jNEIk6WVRrByE/rIC5/7aB1b
KW/hAHGUxgDxqfN1hCjfx47UE/7bKIIArnQQpTft/id6UeJHA89CQulNw2tvhBKj9XZtbnrUFux2
emSDcufF8mOnrCNYVxJg5x1HhytSR5bZX9nzALjJIwZ4AmCezCoBAZg0nJlsvXmVghzWZn+D1paG
8YmVGBOAw+rlEx3gzyUzWRe8WZU+iJrcZEolkNEHXUBzdXO5v7TNLz6RPxGacqZ2/eNPd5JEfXqW
pNaAmVG7IFi/TqxQVdyBPI/9z3RHIcQkf6m9VnzJE0/k+JHRb6UxzrPOuc74AqvSI1k2++fjMWsz
JumddVS2xsz8jDbRoSKrUuvCOKkjYGr592IzBKa8NYU3DN9VoM6G+U6m2ROF5h5e0WzYUrUNVckk
cXGwBz7eDVdZ+1sVJj7dLrd2eXrs4UFez3c0HgrNrpI06Xf/G7RcERAqVmnLRv7Y8oBayE0CQWUf
40CAhQ6clFiN65JzuXmk0Fy+q+WjyK/FsLUjDc97sGKVsytZmYUL1PsAoNgt42G28LGNcAP5Q0lo
s3goOMjZIoIzqboHkd6L9I74DsrYiXsv7dCpBiDIzctKFEeNeLqi11YSwGr/Xpa9NWfJwtUOVSA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