No error in debug mode, wordpress template can not be loaded

I had given a rest to this problem and returned it back today with a fresh mind.. I noticed that the problem is about file upload function.. I revised the code as below:

$attach_id = media_handle_upload( $file_form_handler, $post_id );                         
if ($attach_id != false){ // if the attachment is loaded, register them as post meta
    $file_load = update_post_meta($attach_id,'_wp_attached_file',$files['name']);                                     
    $attach_data = wp_generate_attachment_metadata( $attach_id, ABSPATH."media/".$files['name'] );
    $file_load = wp_update_attachment_metadata( $attach_id, $attach_data );
    if ($file_load == false) {
        $notice = __('An error occured while setting the post meta for the uploaded file.', TDOMAIN);
    } elseif ($file_load == true) {
        $notice="OK";
    }
} else {
    $notice = __('An error occured while uploading the file.', TDOMAIN);
}