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 8410361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:09:11+00:00 2026-06-10T00:09:11+00:00

Hi i need to send the file name and a file as parameters in

  • 0

Hi i need to send the file name and a file as parameters in http post method i used following code as

string reponseAsString = "";
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];


    ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
    {
        return true;
    };
    string fileToUpload = filepath;
    FileStream rdr = new FileStream(fileToUpload, FileMode.Open);
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); //Given URI is exists
    req.Method = "POST";
    req.ContentLength = rdr.Length;
    req.AllowWriteStreamBuffering = true;
    Stream reqStream = req.GetRequestStream();
    Console.WriteLine(rdr.Length);
    byte[] inData = new byte[rdr.Length];

    // Get data from upload file to inData 
    int bytesRead = rdr.Read(inData, 0, (int)rdr.Length);

    // put data into request stream
    reqStream.Write(inData, 0, (int)rdr.Length);
    rdr.Close();

    // req.GetResponse();
    HttpWebResponse response = (HttpWebResponse)req.GetResponse();

    Stream resStream = response.GetResponseStream();
    string tempString = null;
    int count = 0;

    do
    {
        count = resStream.Read(buf, 0, buf.Length);
        if (count != 0)
        {
            tempString = Encoding.ASCII.GetString(buf, 0, count);
            sb.Append(tempString);

        }
    }

    while (count > 0);


    reponseAsString = sb.ToString();
    reqStream.Close();
}

Here i just send the url and file path with file name as request but required response does not obtained.. but when it run through advanced client it give response in c# .net4 framework

Waiting for your sugessions

  • 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-06-10T00:09:12+00:00Added an answer on June 10, 2026 at 12:09 am

    You could use multipart/form-data request encoding. I guess that’s what your server expects. So:

    string fileToUpload = @"c:\work\somefile.jpg";
    string url = "http://foo.com/upload";
    using (var client = new WebClient())
    {
        byte[] result = client.UploadFile(url, fileToUpload);
        string responseAsString = Encoding.Default.GetString(result);
    }
    

    But this is limited to a single file only. If you needed to upload more than one file or add other simple parameters to the POST body you might need to manually do that. I’ve blogged about a sample class that could be used in this case.

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

Sidebar

Related Questions

I need to send a file to MobileMe via Cocoa. I stumbled across a
I need to send a file to a web service (ebridge) using their SendFile
I've a custom form (created with form API) that need send an uploaded file
Dear friends, I need your help. I need to send .bmp file to another
I need to be able to send a file to another website from server-side
I have a file, and I need to send its contents to a function.
HI I have an xml file with 500KB size which i need to send
I am opening a file which has 100,000 URL's. I need to send an
In a powerbuilder 12.5 I need to generate a zip file to send by
I have an XML file which I need to parse using PHP and send

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.