Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
Questionsimple code for game Pin
cicill26-Oct-14 15:23
cicill26-Oct-14 15:23 
AnswerRe: simple code for game Pin
BillWoodruff26-Oct-14 16:32
professionalBillWoodruff26-Oct-14 16:32 
AnswerRe: simple code for game Pin
Mycroft Holmes26-Oct-14 19:20
professionalMycroft Holmes26-Oct-14 19:20 
AnswerRe: simple code for game Pin
Pete O'Hanlon26-Oct-14 21:38
mvePete O'Hanlon26-Oct-14 21:38 
GeneralRe: simple code for game Pin
harold aptroot27-Oct-14 4:29
harold aptroot27-Oct-14 4:29 
QuestionData binding in wpf Pin
rajeevanagaraj25-Oct-14 2:16
rajeevanagaraj25-Oct-14 2:16 
AnswerRe: Data binding in wpf Pin
Mycroft Holmes25-Oct-14 13:32
professionalMycroft Holmes25-Oct-14 13:32 
QuestionUpload and Save Image Using Webservice Pin
ASPnoob24-Oct-14 23:59
ASPnoob24-Oct-14 23:59 
Hi all, I have a web page that allows users to drag an image from their desktop on to a box that had been designated as a droppable box. Once the image is dropped it will be sent to a web service to be saved in a folder on the server. The following is the Javascript I'm using to send the image from the frontend to the webservice.
JavaScript
function ImageUpload(file) {
                 xhr = new XMLHttpRequest();
                 xhr.open('post', 'SaveImageService.asmx', true);
                 xhr.setRequestHeader('Content-Type', "multipart/form-Data");
                 xhr.setRequestHeader('X-File-Name', file.fileName);
                 xhr.setRequestHeader('X-File-Size', file.fileSize);
                 xhr.setRequestHeader('X-File-type', file.fileType);
                 xhr.send(file);
            };


I am using the following code in my web service to save the posted image in a folder called Images. I'm not certain if the project folder name should be included as part of the folder path when I specify where to save the uploaded images. I tried including and excluding the project folder name but it didn't help.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;


namespace ImageUpload
{
    /// <summary>
    /// Summary description for SaveImageService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class SaveImageService : System.Web.Services.WebService
    {

        [WebMethod]
        public void SaveImage()
        {
            var httpRequest = HttpContext.Current.Request;
            foreach (string file in httpRequest.Files)
            {
                var postedFile = httpRequest.Files[file];
                var filePath = HttpContext.Current.Server.MapPath("~/Images/" + postedFile.FileName);
                postedFile.SaveAs(filePath);
            }
        }
    }
}


I am getting response status of 500 internal server error. Please look at the code above and point out any problem you see. Thanks in advance for your help.

modified 25-Oct-14 9:21am.

AnswerRe: Upload and Save Image Using Webservice Pin
CAReed25-Oct-14 4:25
professionalCAReed25-Oct-14 4:25 
GeneralRe: Upload and Save Image Using Webservice Pin
ASPnoob25-Oct-14 7:05
ASPnoob25-Oct-14 7:05 
AnswerRe: Upload and Save Image Using Webservice Pin
Nathan Minier27-Oct-14 1:53
professionalNathan Minier27-Oct-14 1:53 
QuestionApplication could not start error 0xC0000006 starting C# .NET 2.0 program Pin
eljainc24-Oct-14 9:12
eljainc24-Oct-14 9:12 
AnswerRe: Application could not start error 0xC0000006 starting C# .NET 2.0 program Pin
Dave Kreskowiak24-Oct-14 10:26
mveDave Kreskowiak24-Oct-14 10:26 
GeneralRe: Application could not start error 0xC0000006 starting C# .NET 2.0 program Pin
eljainc24-Oct-14 10:39
eljainc24-Oct-14 10:39 
GeneralRe: Application could not start error 0xC0000006 starting C# .NET 2.0 program Pin
Garth J Lancaster24-Oct-14 11:55
professionalGarth J Lancaster24-Oct-14 11:55 
GeneralRe: Application could not start error 0xC0000006 starting C# .NET 2.0 program Pin
eljainc26-Oct-14 1:50
eljainc26-Oct-14 1:50 
GeneralRe: Application could not start error 0xC0000006 starting C# .NET 2.0 program Pin
Dave Kreskowiak26-Oct-14 5:17
mveDave Kreskowiak26-Oct-14 5:17 
QuestionApplication has stopped responding Pin
eljainc24-Oct-14 7:31
eljainc24-Oct-14 7:31 
AnswerRe: Application has stopped responding Pin
Richard Andrew x6425-Oct-14 9:34
professionalRichard Andrew x6425-Oct-14 9:34 
QuestionC sharp and CRC's and polynomials Pin
turbosupramk324-Oct-14 3:13
turbosupramk324-Oct-14 3:13 
AnswerRe: C sharp and CRC's and polynomials Pin
BillWoodruff24-Oct-14 3:42
professionalBillWoodruff24-Oct-14 3:42 
GeneralRe: C sharp and CRC's and polynomials Pin
turbosupramk324-Oct-14 5:42
turbosupramk324-Oct-14 5:42 
GeneralRe: C sharp and CRC's and polynomials Pin
Pete O'Hanlon24-Oct-14 6:08
mvePete O'Hanlon24-Oct-14 6:08 
GeneralRe: C sharp and CRC's and polynomials Pin
turbosupramk324-Oct-14 6:47
turbosupramk324-Oct-14 6:47 
GeneralRe: C sharp and CRC's and polynomials Pin
BillWoodruff24-Oct-14 9:22
professionalBillWoodruff24-Oct-14 9:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.