Charlie Murphy was gracious to the end ... taking time for a fan weeks before his death.

The pic was snapped March 11 at Dallas/Fort Worth International Airport. Michael Brodie asked Charlie for a pic before boarding a plane for Newark, and Charlie was more than accommodating.

Michael says Charlie was super nice.

Turns out Charlie was in and out of the hospital, undergoing chemo but kept his illness secret to almost everyone.

TMZ broke the story ... Charlie died Wednesday after battling leukemia.