Skip to main content

Uploading Images and other stuff

Well, here it comes, the moment you've all been waiting for! ... Probably not - oh well. I think I have image uploads up and working now (auto-thumbnailing isn't there yet) but it *is* smart enough to remove any damaging url characters (more on those in a bit) and to make sure it isn't going to overwrite any other images already in the folder! How cool is that?

It turns out certain characters are not allowed in the path of a URL... go figure right? They seem to be the following symbols: . : & ?. Thankfully I've learned quite a bit about using regular expressions so removing them in the code is quite easy, just one simple function call. Checking them in SQL server, however, is an entirely different matter! Check this out:

SET @Title =
  REPLACE(
    REPLACE(
      REPLACE(
        REPLACE(
          REPLACE(
            REPLACE(@Title , ' ', ''),
          '?', ''),
        '.', ''),
      '&', ''),
    ':', ''),
  '+',
'');

which does the same exact thing as

Regex.Replace(szPath, @"[\.&:\?]", String.Empty);

minus stripping the + and space characters.

Anywho, the reason you are here... drumroll please...

Small screenshot of the PC game, Oblivion, depicting a church with lit stained glass windows reflecting in the water at night.

WOOHOO! IT WORKED! YAYAYAYAYAYAYAY!

That small image above is a picture from the awesome game of Oblivion (with a few mods of course (and a few mods meaning 100+)). Oh, and comments will be coming soon... since I want to show off my AJAX script that I wrote.