The PHP file will not pass the Wordpress variable correctly


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:

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;

$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.

Instead of

global $user_login , $user_email;


global $current_user;
$user_login = $current_user->user_login;
$user_email = $current_user->user_email;

For reference, see