|
How best to approach introducing new development standards into a team |
One of the issues I've been faced with is applying a hard and fast set of standards to a team of developers, whilst maintaining a balance of getting work out the door.
I can't just wade into the team with new process and Quality Assurance routines and not expect there to be a few bumps in the road.
|
Handling CFfile upload 'accept' file type errors |
I was working on a system recently that allowed a user to upload images onto the server. It was restricted to files types of images, more specifically 'jpeg' and 'gif' files.
This is easily done with the 'accept' parameter, as documented in the ColdFusion documentation:
2
3Limits the MIME types to accept. Comma-delimited list. For example, the following code permits JPEG and Microsoft Word file uploads:
4accept = "image/jpg, application/msword"
5
6The browser uses the file extension to determine file type.
It is important to note here that it is the browser uses the file extension, so renaming an exe to jpg would fool it entirely.
Issues arise when you don't handle an invalid file upload in a friendly manner. In this case when a user tried to upload an incorrect file type they saw a nasty unformatted error message stating that the request could not be processed as the file was the wrong Mime type.
You cannot tell what the file type is until you attempt to upload it, so wrap your cffile tags in a simple try-catch and handle any errors in the same fashion as you normally would, I.E. by handling the system message and instead displaying a nice, user friendly message that doesn't sound like it was written by robots.
2
3<cffile action="upload" destination="#request.uploadPath#" fileField="form.new_image" accept="image/jpeg, image/gif" nameConflict="overwrite">
4
5<cfcatch>
6
7 <cfset attributes.errors.type = 'error'>
8 <cfset attributes.errors.message = "The type of file you have tried to upload is not allowed, please select a jpg or gif.">
9 <cfset request.continue = false>
10
11</cfcatch>
12
13</cftry>
|
Web Accessibility 101 - What is it, and why do it? |
This is the first of a series of articles relating to Web Accessibility, breaking down how I understand each aspect of it, including things like best practice coding, testing, what your mark-up really tells impaired users and the general theory behind creating Accessible content. I'll also try and point out any tips I've uncovered to try and smooth out the, sometimes rock, path to validating a site as Accessibly compliant.
|
The Coldfusion Hash() function decoded - kind of |
I've always believed that using the hash() function in ColdFusion is a one way process. If I wanted to reverse a string I had to use encode() and decode(). The Adobe documentation states that "It is not possible to convert the hash result back to the source string" - Adobe Docs for Hash().
Strictly speaking this is still true, but some bright spark has decided to host an MD5 string database and provide a lookup service.