bad-request ' ); // Get the POST vars $id = $_POST['id']; $tmp_filename = $_FILES['file']['tmp_name']; $old_filename = $_FILES['file']['name']; // Get the file extension $ext = getFileExt($old_filename); // Hash it! $filename = md5($old_filename.time()).$ext; // Define some vars $path = JAPPIX_BASE.'/store/avatars/'.$filename; // Define MIME type if($ext == 'jpg') $ext = 'jpeg'; $mime = 'image/'.$ext; // Unsupported file extension? if(!preg_match('/^(jpeg|png|gif)$/i', $ext)) exit( ' forbidden-type ' ); // File upload error? if(!is_uploaded_file($tmp_filename) || !move_uploaded_file($tmp_filename, $path)) exit( ' move-error ' ); // Resize the image? if(!function_exists('gd_info') || resizeImage($path, $ext, 96, 96)) { try { // Encode the file $binval = base64_encode(file_get_contents($path)); // Remove the file unlink($path); exit( ' '.$mime.' '.$binval.' ' ); } catch(Exception $e) { // Remove the file unlink($path); exit( ' server-error ' ); } } // Remove the file unlink($path); // Something went wrong! exit( ' service-unavailable ' ); ?>