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

  • SEARCH
  • Home
  • 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 6217445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:25:40+00:00 2026-05-24T07:25:40+00:00

I have an ASP.net webforms site, using jQuery to trigger script methods in asmx

  • 0

I have an ASP.net webforms site, using jQuery to trigger script methods in asmx web services.
Now I need to add a page which allows a user to upload a file, along with some other properties (like description, creation date etc.)

I understand that there are some jQuery plugins for uploading a file more nicely than the MS file-uploader control (such as uploadify).
however, I can’t figure out how to:
1. make it work with script services (I saw some examples using MVC or using http handler, but none using script service
2. In addition to the file itself, I want to be able to send more data along.

any ideas?
thanks

  • 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-24T07:25:41+00:00Added an answer on May 24, 2026 at 7:25 am

    use this one for same task…

    file uploader

    this is code i’ve written for handler

    <%@ WebHandler Language="C#" Class="Upload" %>
    
    using System;
    using System.Web;
    using System.IO;
    using System.Collections.Generic;
    
    public class Upload : IHttpHandler
    {
    
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string filePath = "uploads//";
                string newFilename = Guid.NewGuid().ToString();
    
                string nonIEFilename = context.Request.Headers["X-File-Name"];
    
                if (!string.IsNullOrEmpty(nonIEFilename) || context.Request.Files.Count > 0)
                {
                    // if IE
                    if (string.IsNullOrEmpty(nonIEFilename))
                    {
                        HttpPostedFile file = context.Request.Files[0];
                        string[] filenamesplit = file.FileName.ToLower().Split('.');
    
                        newFilename = string.Format("{0}.{1}", newFilename, filenamesplit[1]);
                        file.SaveAs(context.Server.MapPath(string.Format("{0}{1}", filePath, newFilename)));
                        context.Response.Write(string.Format("{{\"path\":\"{0}uploads/{1}\"}}", context.Request.Url.AbsoluteUri.Replace("upload.ashx", string.Empty), newFilename));
                    }
                    else // non IE browsers
                    {
                        string[] filenamesplit = nonIEFilename.ToLower().Split('.');
                        newFilename = string.Format("{0}.{1}", newFilename, filenamesplit[1]);
    
                        using (FileStream filestream = new FileStream(context.Server.MapPath(string.Format("{0}{1}", filePath, newFilename)), FileMode.OpenOrCreate))
                        {
                            Stream inputStream = context.Request.InputStream;
                            inputStream.CopyTo(filestream);
                            context.Response.Write(string.Format("{{\"path\":\"{0}uploads/{1}\"}}", context.Request.Url.AbsoluteUri.Replace("upload.ashx", string.Empty), newFilename));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Errors.addError("Upload.ProcessRequest()", ex);
            }
        }
    
        private bool IsAllowed(string file)
        {
            bool isAllowed = false;
    
            List<string> allowedExtensionsList = new List<string>();
            allowedExtensionsList.Add("jpg");
            allowedExtensionsList.Add("png");
            allowedExtensionsList.Add("gif");
            allowedExtensionsList.Add("bmp");
    
            string[] filenamesplit = file.ToLower().Split('.');
    
            for (int j = 0; j < allowedExtensionsList.Count; j++)
            {
                if (allowedExtensionsList[j] == filenamesplit[1].ToLower())
                {
                    isAllowed = true;
                }
            }
    
            return isAllowed;
        }
    
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    
    }
    

    i have two cases for IE and other browsers because they post files in different forms

    as for additional data, if it’s text you can send it via get while calling service

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

Sidebar

Related Questions

Some site I'm programming is using both ASP.NET MVC and WebForms. I have a
I have a web site that runs both classic ASP and ASP.NET Webforms. The
I'm trying to develop my first site in ASP.Net using Web Forms. I have
I have almost completed an ASP.NET webforms website using jQuery Mobile. I am stuck
I am making an asp.net, c#, webforms web site for sales clerks. I have
I have the following ajax email submit routine on my ASP.NET WebForms web site:
I have a asp.net webforms page in which I'm using the jqGrid component. The
Retrofitting ASP.NET WebForms themes to an old application I have a need to theme
When using ASP.net webforms my usual solution would have following type of setup -
I have a simple web app built in asp.net webforms c# where and how

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.