Delete files posted by upload script within PHP

Ok so I used Valum’s Upload script to make a custom file uploader feature within my buddypress profiles. Success there, but the failure comes when I appended a “delete” link to the list item that is returned. That link has an onclick event that uses WP ajax to then delete the file from the location it was just uploaded to.

The Ajax callback function is as follows:

* Delete Files
add_action("wp_ajax_delete_file", "delete_file");
add_action("wp_ajax_nopriv_delete_file", "delete_file");
function delete_file(){
$file = $_POST['file'];
$response = json_encode( array(
'success' => true
} else {
$writeable = (is_writable($file))? "YES" : "NO";
$exist = (file_exists($file))? "YES" : "NO";
$response = json_encode( array(
'error' => FALSE,
'file' => $file,
'writable' => $writeable,
'exist' => $exist
// response output
header( "Content-Type: application/json" );
echo $response;
// IMPORTANT: don't forget to "exit"

The function fires and everything works as expected except the file does not delete and I now have the following message in my console which doesn’t make sense because as you’ll see it says the file doesn’t exist but the file path is included and you can link to it and see that it exist.

The Response:

error: false
exist: "NO"
file: ""
writable: "NO"

I checked the permissions through my FTP client (Filezilla) and I have 777 on all directories within user_uploads. Any guidance here would be awesome!