10.3. Last Remaining Issues

You get a call from Claudia. She's very excited because her team has successfully uploaded a great deal of information onto the site. "However, we have a little problem," she says.

It appears that whenever you create a new product in the system and don't upload a file, the system freezes. The same thing happens when you edit an existing product and don't upload a new image for it.

"One more thing," she says. "I know it's kind of a pain, but my mother got on the test site the other day, and nothing worked for her. I talked to her about it, and I think she's got a really old browser that doesn't support all the things we have on the site."

You assure Claudia that you will look into the file upload issue and that one of the last tasks you had before launch was the installation of a JavaScript and cookie sniffer to ensure that everyone had a browser that could handle the site's AJAX.

10.3.1. Debugging File Uploads

The file upload issue is a simple one to fix. You have two model functions that do the heavy lifting of adding/updating products in the database: addProduct() and updateProduct(). Both of these live in the MProducts model.

Each of these functions contains a section in which you set the config parameters for the incoming file. All you have to do is wrap those sections of the code that deal with file uploads with a simple test to see if $_FILES has something in it, and then, right before each specific upload, check to see if there is a name associated ...

Get Professional CodeIgniter® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.