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
karthik saraswatula
NA
11
4.9k
How to save Images to a folder using Web Services in Asp.net
Aug 24 2015 1:42 AM
Hi,
I'm uploading an image from mobile to web using web services..But now i need to save the image to a folder.But i'm getting an exception
"
exception in ImageuploadSystem.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at HSC_WCF_MOBILE.HSCMOBILE.UploadFile(String filename, String base64String)
at HSC_WCF_MOBILE.HSCMOBILE.ImageUpload(UploadImage1 objUploadImage)"..Please help me out..Below is my web service Code..
public String ImageUpload(UploadImage1 objUploadImage)
{
string response = string.Empty;
try
{
bl = new BLLayer();
string imageName = objUploadImage.lstObjUploadImage[0].Name;
string imageCode = objUploadImage.lstObjUploadImage[0].Image;
TraceService("Inside method imageupload");
TraceService("imageupload Name:" + imageName);
TraceService("imageupload Image in string format:" + imageCode);
if (objUploadImage.lstObjUploadImage[0].Image != null)
{
string imagesUrl = UploadFile(imageName, imageCode);
TraceService("imageupload Image in URL:" + imagesUrl);
if(imagesUrl != null)
{
response = "success";
}
else
{
response = "failure";
}
}
else
{
response = "failure";
}
}
catch (Exception ex)
{
TraceService("exception in Imageupload" + ex.ToString());
}
finally
{
bl = null;
}
return response;
}
public string UploadFile(string filename,string base64String)
{
byte[] imagebytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imagebytes, 0, imagebytes.Length);
ms.Write(imagebytes, 0, imagebytes.Length);
Image image = Image.FromStream(ms, true);
string imageUrl = @"E:\HSC_2.0.9_29thJuly2015\HSC\images\Barcodes";
image.Save(imageUrl + filename + ".jpg", ImageFormat.Jpeg);
return imageUrl;
}
Thanks & Regards,
Karthik S
Reply
Answers (
1
)
.net programs
What is SOAP ?