Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7026331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:06:10+00:00 2026-05-28T00:06:10+00:00

UPDATED QUESTION: I’m trying to create a form which passes subject, content, and a

  • 0

UPDATED QUESTION:

I’m trying to create a form which passes subject, content, and a file to a webservices. This is what I have so far and was wondering if someone could tell me if I am going in the right direction and how to do the bits which I have highlighted in the comments in the asmx file

The HTML:

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server"></script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form action="files.asmx/CaptureFile" enctype="multipart/form-data" method="post">
        <input type="text" name="subject" /><br />
        <input type="text" name="content" /><br />
        <input type="file" name="filedata" /><br />
        <input type="submit" value="Upload" />
    </form>
</body>
</html>

The WebService:

<%@ WebService Language="C#" Class="Files" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Script;
using System.Web.Script.Services;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

[ScriptService]
public class Files : WebService {
    SqlConnection connection;
    SqlCommand command;
    SqlDataReader reader;

    int intAffectedRows;

    [WebMethod()]
    public int CaptureFile(string subject, string content, byte[] filedata)
    {
        // somehow reconstruct the filedata to an actual file saved on the server

        // save subject, content, and filename to database
        using (connection = new SqlConnection(ConfigurationManager.AppSettings["connString"]))
        {
            using (command = new SqlCommand("query to save subject content and filename_only to database", connection))
            {
                command.Parameters.Add("@subject", SqlDbType.VarChar, 255).Value = subject; 
                command.Parameters.Add("@content", SqlDbType.VarChar, 255).Value = content;
                command.Parameters.Add("@filedata", SqlDbType.VarChar, 255).Value = filedata; // need to save filename here, not file binary data

                connection.Open();
                intAffectedRows = command.ExecuteNonQuery();
                connection.Close();
            }
        }

        return intAffectedRows;
    }
}

———-

ORIGINAL QUESTION:

I understand how to send standard text to a webserver, process it, then send something back, i.e.

[WebMethod()]
public List<Notification> GetNotification(int id)
{
    // do processing here

    // return something back
    return "Notification text";
}

My ajax looks like this:

$.ajax({
    type: 'POST',
    url: '/webservices/notifications.asmx/GetNotification',
    data: '{id: ' + number + '}',
    contentType: 'application/json; charset=utf-8',
    dataType: 'json',

How do I send a file? The file will be a .pdf or a .doc file so I can save it to the server along with some text. So, I would want a textbox for subject, and select file button/textbox to select the file, and a submit button. When the 2 textboxes are filled in and the submit button is clicked, it should send the subject and file to the webservice, whwere the webservice will save the subject and file location to a database, and save the actual file to the server.

Also, I am developing on an intranet environment, and IE has full trust to the local intranet.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:06:11+00:00Added an answer on May 28, 2026 at 12:06 am

    How do I send a file?

    You can’t send files using AJAX simply because using javascript you don’t have access to the file system on the client computer so you cannot get the file contents. If you want to send files to a web server you could use an <form> with file input and enctype="multipart/form-data" which would post to a server side script. This script could then call the web service and transmit the file contents as an array of bytes for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

N.B THIS QUESTION HAS BEEN UPDATED, READ FURTHER DOWN Hi, I want to create
Edit: The below question was answered by this . I have a new updated
Updated: This question contains an error which makes the benchmark meaningless. I will attempt
SORRY FOR THIS CONFUSION: UPDATED QUESTION: I'm trying to remove a list item from
Updated question to be more generic: I have the following code. When you swap
Edited this question because of my bad examples.. Here is my updated question: Would
(NOTE: I've updated this question from the initial inquiry about child containers towards creating
This is probably a very newbie question but what I'm trying to do is
I was trying to solve this Project Euler Question . I implemented the sieve
UPDATED QUESTION: Hello , so I was able to create the modal view curl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.