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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:06:32+00:00 2026-06-14T17:06:32+00:00

I want to upload a file from codebehind. I would like to explain my

  • 0

I want to upload a file from codebehind.

I would like to explain my situation a bit.

My existing code is..

I have a fileupload control.

<asp:FileUpload ID="fuSRForm" runat="server" class="file"/>

Then from the codebehind, I check the conditions for that control.

if (fuSRForm.HasFile && (fuSRForm.PostedFile.ContentType.ToString().Trim().ToLower().Contains("pdf") || fuSRForm.PostedFile.ContentType.ToString().Trim().ToLower().Contains("application/vnd.openxmlformats-officedocument.wordprocessingml.document") || fuSRForm.PostedFile.ContentType.ToString().Trim().ToLower().Contains("msword")))

And if the conditions are met,

I used the Sitecore API to upload the file.

This is the part of uploading API.

                        // creating necessary arguments to be passed to the processor
                        UploadArgs args = new UploadArgs();

                        // adding http files collection
                        args.Files = base.Request.Files;

So, the API is grabbing all posted files by using base.Request.Files


My new situation is that I creat a pdf file when the user click Submit.

Then I save it in a folder named asyncupload

After that I have to upload it to Sitecore using the same API

So, I tried to change the base.Request.Files to my file.

But I am unable to change that.

So, I will have to upload my file using FileUpload control.

            FileUpload tempFU = new FileUpload();
            tempFU.PostedFile= ????
            args.Files = base.Request.Files;

I am stuck right here. I can either post my file from code behind or change the base.Request.Files to my file.

either way, I am stuck. Anyone can solve that?

  • 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-14T17:06:35+00:00Added an answer on June 14, 2026 at 5:06 pm

    I’m not sure what your end goal here is. Maybe you could post some more code if I’ve understood you incorrectly. But here’s how to add a file to the Media Library: Brian Pedersen: Adding a file to the Sitecore Media Library programatically

    If you are using an <asp:FileUpload /> control, then you can save the file to server disk like this:

    string filePath = Path.Combine(Server.MapPath("~/"), "upload/tempfile.tmp");
    FileUpload1.SaveAs(filePath);
    

    Then call the AddFile method from the link I provided above:

    AddFile(filePath);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one audio file captured from my iphone. I want to upload this
I want to upload 30GB with asp.net file upload control, i have heard that
I would like to upload a file from android device to server using php.
I would like to upload file from the client to the server with a
I have a facebook canvas application and I want to upload a file from
I have to upload one file from client using <asp:FileUpload> Button. I have to
In my application I want to upload file from SD card to my server.
I want to switch a file upload from FTP to SFTP. But I cannot
I want to go to select a file from sdcard and upload it to
I want to upload a file(photo) from Flex to Rails and then send a

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.