Cannot View Case Attachments

Symptom:

You attach a file to a case in FogBugz, but when you click on the link to that attachment you can't view it. There are different permutations of this type of problem, some apply only to Windows and some to non-Windows as well, some only to 3.x and some are 4.x as well. All are discussed in this article.  

Error Message: You may get the following message:

First, find your FileUploads folder, if you have one (FogBugz for your Server only):

Missing User Permissions (applies to FogBugz for your Server for Windows versions 3 and later):

The user account FogBugz uses in IIS may not have permission to write to the FileUploads directory (if use FogBugz 4.0 or later and you don't have this folder, then this is not your problem and you can skip to the next one below).

Solution:

Missing Primary Key (applies to all FogBugz for your Server versions):

Look in the FileUploads folder. Is there just one folder, named 0? (That's a zero.) Then you have probably lost a primary key in the database.

Solution:

Look at the design of both your Bug table and your BugEvent table in your FogBugz database. The ixBug and the ixBugEvent fields must be the primary key, and they must be the "identity", set to auto-increment, for those tables respectively. If they are not, all your attachments will get thrown into this folder named 0 (zero) and the links to these attachments will not work.

Invalid attachment name (applies to all versions of FogBugz):

Your file attachment may have an invalid character in it, such as the ampersand: &. The solution is the same as below.

Space in filename, when using Mozilla or FireFox (applies to all versions of FogBugz):

There is a known issue with FogBugz in Mozilla/FireFox, wherein a space is not allowed in a file attachment link.

Solution:

It may be easiest for you to have the file re-named and then re-attached. Otherwise, here's how to recover this situation:

  1. Click on the attachment link. The URL in your browser should now look something like this:

    http://localhost/fogbugz/download.asp?ixBugEvent=126&sFileName=q&a.doc&sFile=yes

  2. Look at the sFileName part.
    A. If there is an ampersand in your sFileName, replace it with the following: %26
         So, in my example I would change q&a.doc to q%26a.doc
    B. If using a Mozilla browser, replace any spaces in the name with the following:  %20

  3. If the problem you're having is indeed Problem 3 or 4, you will now be able to view your file. Save it and re-attach it to the case for future viewing (so no-one will need to take these rectification steps again).

  4. Then delete the original bad link.