Q:

PHP file won't pass Wordpress Variable Properly

Have a really weird problem and can't figure out. I'm using 'UPLOADIFY' to upload images from a small web app. It was working perfectly for months, then all of a sudden stopped working. Ideally I want to grab the logged in Wordpress user's username and add it to the image filename.
Here is part of my uploadify file:
<?php
include_once($_SERVER['DOCUMENT_ROOT'] .'/wp-config.php');
include_once($_SERVER['DOCUMENT_ROOT'] .'/wp-load.php');
include_once($_SERVER['DOCUMENT_ROOT'] .'/wp-includes/wp-db.php');
global $user_login , $user_email;
      get_currentuserinfo();

$variableuser_id = $user_login;
$ses_id = $variableuser_id;
$ses_id = "1" . $ses_id . "z";
echo "This is a test " . $ses_id;

Then later in uploadify I have:
if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $ses_id . "-" . str_replace(" ", "", $_FILES['Filedata']['name']);

So...when I upload an image using uploadify it will not add the username into the image name, it does ad the "1" and the "z" to the file name but is totally missing the username in the middle.
If I launch the uploadify.php file regular in my browser it will display "This is a test 1adminz" as it should for being logged in as admin. Any ideas? I'm stumped! BTW I know $ses_id isn't ideal varname but it was just carrying over in my code from when I had a session ID named that.

A:

Ok I really can't explain this but I found a solution that fixed uploadify on each of my installs on a few different servers.
Took this line
$targetFile = rtrim($targetPath,'/') . '/' . $ses_id . "-" . str_replace(" ", "", $_FILES['Filedata']['name']);

Then commented half of it out
$targetFile = rtrim($targetPath,'/') . '/' . $ses_id . "-"; // . str_replace(" ", "", $_FILES['Filedata']['name']);

Surprise suprise, it renames an uploaded image now with the $ses_id variable combined with '-'. No image suffix obviously.
So for the hell of it, I uncommented out that ending part, and low and behold IT WORKS! MIND BLOWN!
This makes no sense to me but solved on multiple servers!

