Hello and welcome to HCM,
Cramping pain and spasms in upper thigh are suggestive of some muscular problem.
Relief from pain while lying down with leg elevated further shows that pain is associated with contraction and relaxation of muscles of thigh and hip.
Clinical assessment of muscles of hip and thigh is required to know the cause of pain and spasms.
There is a possibility of strain or
sprain of the muscles of thigh or leg.
Strain and sprain can occur due to pulling of muscles or tendon.
Pulling of muscle or tendon can occur due to wrong movement or wrong posture.
Thus, I suggest you to consult an orthopedician for clinical assessment, investigations and thus management.
In the meanwhile you can take pain killers to relieve pain.
Thanks and take care
Dr Shailja Puri