Damn You PHP

I'm writing a script to for a flash game site. Yes, I know there are a lot of those out there, and no, I don't care. Anyways, I started working on the admin panel, where you could upload the game, but I kept having a problem with moving the uploaded file.

Here's the line:

if(move_uploaded_file($_FILE['swf']['tmp_name'],$targetpath))

It always would evaluate to false, and I could not figure out why. Up until now, I've just blamed it on Vista's crappiness. I tried changing the upload path, thinking that maybe it didn't have the rights to that certain folder. Tried closing down XAMPP and doing 'Run As Administrator'. Even decided to download and install the newest version of XAMPP (I've been meaning to do this anyways though), and nothing worked.

After some good staring, I realized that I can't spell FILES. So, now:

if(move_uploaded_file($_FILES['swf']['tmp_name'],$targetpath))

Works like a charm. So after all that hell, it was a simple typo. Then I thought, why the hell didn't PHP catch the error, and it turned out E_NOTICE was turned off. I guess some scripts would break with E_NOTICE on for header sending or cookie setting, but since XAMPP is almost completely for development, I would kinda expect it to be on by default.

Anyways, always check php.ini files.

One Comment

  1. [...] Nothing to see here… < Damn You PHP [...]

Leave a Reply