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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:22:44+00:00 2026-05-26T06:22:44+00:00

First, here is my code: private Shoe ProcessForm(Shoe shoe, HttpPostedFileBase image) { try {

  • 0

First, here is my code:

private Shoe ProcessForm(Shoe shoe, HttpPostedFileBase image)
{
    try
    {
        shoe.Slug = CMSHelper.SanitizeTitle(shoe.Name);
        shoe.LastModification = DateTime.Now;

        if ((image != null) && (image.ContentLength > 0))
        {
            string fileName = String.Concat(shoe.ShoeId, Path.GetExtension(image.FileName));
            shoe.Image = fileName;

            string filePath = Path.Combine(Server.MapPath(shoe.ImagePath), fileName);
            image.SaveAs(filePath);
        }
    }
    catch (Exception e)
    {
        throw e;
    }

    return shoe;
}

Locally, this code works fine. Directories’ permissions are fine. And it has worked before randomly on other servers (I tested this code on 4 or 5 different servers while I was testing VPS providers).

But if I try to run it from my home computer, everything passes alright, there’s a file name saved in the database but no file is uploaded. And no exceptions are given!!!

I’ve been trying to fix this for almost three days and so much useless hours, please help me… I just don’t see what’s wrong with this…

  • 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-26T06:22:45+00:00Added an answer on May 26, 2026 at 6:22 am

    I finally did a workaround which is doing very fine. I even asked at my job and everyone said there was nothing wrong at all. So screw it here’s what I did:

    Instead of calling .SaveAs() I made a method which is :

    public static void WriteFileFromStream(Stream stream, string toFile)
    {
        using (FileStream fileToSave = new FileStream(toFile, FileMode.Create))
        {
            stream.CopyTo(fileToSave);
        }
    }
    

    I call it like this:

    CMSHelper.WriteFileFromStream(image.InputStream, filePath);
    

    And that’s it.

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

Sidebar

Related Questions

here is the code private ResultSet rsResult; try { rsResult = DBProcess.statement.executeQuery(SELECT * FROM
First off here is the code! <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
first post here, and probably an easy one. I've got the code from Processing's
Let me first put the code snippets here. I am just using the ASP.NET
Here is the code: string str; cin>>str; cout<<first input:<<str<<endl; getline(cin, str); cout<<line input:<<str<<endl; The
here's the main code at first I thought is was the message box but
Here is the first part of my controller code: public class ControlMController : Controller
First, here is the C# code and the disassembled IL: public class Program<T> {
First, to make my job explaining a bit easier, here's some of my code:
So, here's my question: Why won't the code in the first snippet work when

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.