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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:49:59+00:00 2026-05-19T11:49:59+00:00

I am in a rather unusual pickle. I am modifying an image uploader and

  • 0

I am in a rather unusual pickle. I am modifying an image uploader and I thought I had it working. It needed to:

  1. take a file from the client and upload it to server.
  2. If file is an image, perform resizing operations on it.
  3. If file is an image, create a thumbnail.

What I have works great when uploading images with Internet Explorer 8. But, when I upload images using Chrome, or Firefox3.+, the image gets uploaded but steps 2 and 3 are not performed. I don’t get any server errors or anything. As 2 and 3 are steps that are performed on the server I have no idea how a change in browser could effect them.

I’m not sure if it has anything to do with my checking for whether the file is an image or not. But, for the sake of being thorough, here’s the code I use:

try
{
    string Filename = FileSystemUtilities.CleanupFilename(Path.GetFileName(hpf.FileName));
    Filename = hpf.FileName;
    string FileToSave = DestDir + Path.DirectorySeparatorChar + Path.GetFileName(Filename);
    hpf.SaveAs(FileToSave);
    bool IsImageFileType = ImageUtilities.IsImage(Filename, imageExtensions);

    // below does not seem to execute when using non ie browser
    // everything is smooth sailing when using ie.
    if (IsImageFileType)
    {
        ImageUtilities.ResizeImageIfNecessary(FileToSave, mainMaxWidth, mainMaxHeight);
        ImageUtilities.CreateThumbnail(FileToSave, thumbMaxWidth, thumbMaxHeight);
    }

    ValidOperation++;
    sb.AppendFormat("{0} uploaded successfully<br/>", Filename);
}

Any thoughts? Why would server side code behave differently based on browser?

Edit: ImageUtilities.IsImage()

    public static bool IsImage(string file, string[] imageExtensions)
    {
        file = Path.GetFullPath(file);

        if (File.Exists(file))
        {
            string CurrentFileExtension = Path.GetExtension(file);
            return imageExtensions.Count(x => x == CurrentFileExtension) > 0 ? true : false;
        }
        else
        {
            return false; //file doesn't exist
        }
    }
  • 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-19T11:50:00+00:00Added an answer on May 19, 2026 at 11:50 am

    This difference would be caused by a difference in the filename sent by the browsers.
    For example, some browsers include the full path.

    Your ImageUtilities.IsImage function can’t handle the filename sent by non-IE browsers.

    EDIT: Your function is very wrong.
    Change it to

    return imageExtensions.Contains(Path.GetExtension(file), 
                                    StringComparer.OrdinalIgnoreCase);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my current project, we got a rather unusual request(to me). The client wants
I came across this rather unusual usage of 'delete'. Just wanted to know if
I have a rather unusual problem, and it is hurting my brain. Problem: Given
I recently came across a rather unusual coding convention wherein the call for a
I need to do a rather unusual thing: manually execute an elf executable. I.e.
While looking on some legacy code, I found a rather unusual construction (for me
I'm adding the star rating plugin from www.fyneworks.com/jquery/star-rating/ and I'm finding the documentation rather
A rather unusual situation perhaps, but I want to specify a private SSH-key to
I came across a rather unusual way to build an object of a class
I am faced with rather unusual situation I will have url in any of

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.