rendered paste body/** * Special AJAX callback for uploads coming from SWFUpload. */function sprout_ajax_insert_asset_swfupload() { dvw($_POST, 'post'); dvw($_FILES, 'files'); dvw($_SESSION, 'session'); // Check for upload error if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0) { header('HTTP/1.1 500 File Upload Error'); if (isset($_FILES['Filedata'])) { $return = array('success' => FALSE, 'message' => $_FILES['Filedata']['error']); print drupal_to_js($return); } exit(0); } $sid = $_POST['PHPSESSID']; $uid = db_result(db_query("SELECT uid FROM {sessions} WHERE sid = '%s'", $sid)); /*if ($uid !== FALSE) { global $user; $user = user_load(array('uid' => $session['uid'])); return user_access('upload files', $user); } // Load Drupal session and get session vars. session_id($session_id); session_decode(sess_read($session_id));*/ global $user; $user = user_load(array('uid'=> $uid)); $rand_key = 'sprout_'. mt_rand(); $_FILES['files']['name'][$rand_key] = $_FILES['Filedata']['name']; $_FILES['files']['type'][$rand_key] = $_FILES['Filedata']['type']; $_FILES['files']['tmp_name'][$rand_key] = $_FILES['Filedata']['tmp_name']; $_FILES['files']['error'][$rand_key] = $_FILES['Filedata']['error']; $_FILES['files']['size'][$rand_key] = $_FILES['Filedata']['size']; $file = file_check_upload($rand_key); dvw($file, 'file'); $values = array( 'title' => $file->filename, 'link' => $file->asset_link, 'folder_tid' => $dest_folder_tid, ); if (sprout_asset_create($values)) { $return = array('success' => TRUE, 'message' => t('Asset was uploaded successfully.')); } else { $return = array('success' => FALSE, 'message' => t('Asset upload was unsuccessful.')); } print drupal_to_js($return); exit;}