HTML PHP Special Characters showing question mark

I was developing a french website for a customer yesterday and at the same time, when I was templating the site to php, I found out that all the french accents got turned into a question mark, �  <– this really..

What’s wrong?

I already had UTF-8 in my headers

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

and it was still not working.


It turns out that I had not saved the file in UTF-8, so I had to open up Notepad++ which is my main coding IDE, and go to Encoding -> Convert to UTF-8 without BOM


Read More

Java: Jakarta Apache Commons FileUpload

After headaches, 7 coffee, 1 Cheese Burger and 7 hours of sleep. I finally got Apache Commons FileUpload to work! : )

My working environment: JDeveloper 10g, Tomcat 5.x and Oracle DB 10g, Apache Commons Lib

The working code:

public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {

// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);

// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();

// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);

try {

// Parse the request
List items = upload.parseRequest(request);

// Process the uploaded items
Iterator iter = items.iterator();

while (iter.hasNext()) {

FileItem item = (FileItem);
if (item.isFormField()) {

String name = item.getFieldName();
String value = item.getString();
if(name.equals(“username”)) {  username= value; }
if(name.equals(“pass”)) {  passwd=value;}
if(name.equals(“email”)) {  email=value;}

} else {

//Process the file upload

// *************************************************
// This is where you would process the uploaded file
// *************************************************
File uploadedFile = null;
String myFullFileName = fileItem.getName(), myFileName =
“”, slashType =
(myFullFileName.lastIndexOf(“\\”) > 0) ? “\\” : “/”;
int startIndex = myFullFileName.lastIndexOf(slashType);
myFileName =
myFullFileName.substring(startIndex + 1, myFullFileName.length());

uploadedFile =
new File(“/home/gulshanbeejan/uploads”,



//Do stuff with fields collected here.. like save in a db?

} catch (Exception e) {

enctype=”multipart/form-data” will only work that way, you cannot use a multipart/form-data and use request.getParameter(“username”); it will never work.

I hope this helps other souls!

Read More

HTML + CSS Image Rollover Effect

To make an html and css rollover effect, the logic behind it is quite simple..

In your html code, you need to place a DIV tag inside a hyperlink. E.g

<a href=”test.html”><div class=”roll”></div></a>

In your css code: you would use the a, a:visited and a:hover to manipulate the Image Rollover. E.g

a .roll, a:visited .roll {





/*The code below is what would trigger the 2nd hover image to appear*/

a:hover .roll {





And that’s the basic technique behind it.. try it and play with the code to understand it better.

Read More