WebIT.ca

Montreal Web Development

Uploaded Excel mime type

Thursday, November 5th, 2009

I’ve been strugling to find the reason behind a malfunctioning Excel upload feature. The problem was that some times, the file would not have the application/vnd.ms-excel mime type. This was a bit of an issue, it was required for invaliding the type of the file.

By luck, a coworker discovered that the Excel file would return a different mime type if the Excel file was open in Excel when it was uploaded. Under these conditions, the mime type is application/octet-stream. In other words, when uploading an open Excel doc, Internet Explorer would have trouble identifying the file type and send along the generic mime-type application/octet-stream.

Bellow is a quick fix that should take care of future problems:

if (   $_FILES['excel_file']['type'] == 'application/vnd.ms-excel'
    || preg_match('/\\.xls$/', $_FILES['excel_file']['name']) ) {
    // continue working on the uploaded file...
}

Ubuntu in VirtualBox

Wednesday, October 21st, 2009

When installing Ubuntu (9.10) in Virtualbox (3.2.0), it’s important to check off the Enable PAE/NX option. Otherwise, powering off the machine will result in a broken boot sequence and an unusable virtual machine.

The option can be found in Settings > System > Processor.

PHP isset()

Sunday, September 20th, 2009

The PHP function isset() is often used to determine the presence of a variable. When the variable is not defined, false is returned. Using isset() is also an easy way to determine whether an array has a given key.

$assoc = array('key' => 'value');
echo isset($assoc['key']) ? 'true' : 'false';
// true
echo isset($assoc['missing']) ? 'true' : 'false';
// false

There is a catch: isset() called on a null variable will return false.

$var = null;
echo isset($var) ? 'true' : 'false';
// false
 
$array = array('key' => null);
echo isset($array['key']) ? 'true' : 'false';
// false

For checking the presence of a key in an array, use the PHP function array_key_exists() instead.

echo array_key_exists('key', $array) ? 'true' : 'false';
// true
 
function has_empty($key, &$array) {
    return array_key_exists($key, $array) && !$array[$key];
}
echo has_empty('key', $array) ? 'true' : 'false';
// true

To determine the presence of a null variable, a custom function is required.

function isvar($var) {
    return isset($var) || @is_null($var);
}
$null = null;
echo isvar($null) ? 'true' : 'false';
// true

Custom Pagination Plugin for WordPress

Monday, August 24th, 2009

Download: Custom Pagination Plugin, Version 1.0

With the Custom Pagination plugin, a user may customize the look of a post’s next and previous links using the HTML editor. It was built by WebIT.ca and funded by DateDaily.com: an online dating and relationship blog.

Read the rest of this entry »

Choosing a Content Management System for Online Publishing

Sunday, June 7th, 2009

Choosing the right CMS (Content Management System) is a necessary step when first starting a site, however small or large. Whatever the system chosen, your primary goal should be to minimize operation cost and increase productivity.  Here is a list of frequently requested core features to satisfy either or both of your goals.
Read the rest of this entry »

WebIT Discussions, Ep. 1: Content is Burger King

Saturday, April 11th, 2009

In the first episode of WebIT Discussions, recorded on Thursday, April 9th, 2009, James Bassil (@jamesbasil) and Liesl Barrell join me, Dimitry Zolotaryov, in discussing traditional publishing, online publishing and the process of moving from the former to the latter.

Download the full MP3 (webitd-09-04-09.mp3, 01:04:06)

Listen to the audio in the browser

Expanding the CMS for new Content

Sunday, March 29th, 2009

A CMS is often expanded when the site requires tools to help publish existing content or introduce new content. Too often, however, the developers are asked to upgrade the CMS without first an idea of what the content is or how it will be presented or used. This inevitably leads to poor development, rewriting and late delivery of a project.

Read the rest of this entry »

On The Radar, Spring ’09

Wednesday, March 11th, 2009

Here are a few technologies and trends I am following this season

Read the rest of this entry »

Working in Publishing as a Developer

Thursday, March 5th, 2009

Whether you’re starting for a top-down, old-style, publishing company or you’re joining a collaborative blog , your tasks as the developer can be grouped into four broad categories. Let’s explore these responsibilities and challenges of programming for a publishing company.

Read the rest of this entry »

On Website Depreciation

Thursday, February 26th, 2009

Is a site ever finished? In a limited way, yes. As the months pass, however, the value of a site degrades. Worse still, with enough time, a site may drive your audience away with it’s dated look, old-style functionality or lack of modern features. How do we handle this depreciation? The key is to become ‘light-weight’: not bogged down with tools and structure, but remain open and flexible to change.

Read the rest of this entry »