An image forming apparatus comprising: a cartridge; and an apparatus main body to which the cartridge is detachably attached, the apparatus main body including: a frame in which an opening portion, through which the cartridge is attached to the apparatus main body, is formed; an opening and closing member configured to move between an open position in which the opening and closing member is opened to expose the opening portion and a closed position in which the opening and closing member is closed to cover the opening portion, the opening and closing member having a supported portion supported by the frame so that the opening and closing member is rotatable about a rotational axis, the opening and closing member having a stacking surface on which a sheet is to be stacked when the opening and closing member is located in the closed position; a discharging roller configured to discharge the sheet in a discharging direction onto the stacking surface when the opening and closing member is located in the closed position; and a regulating wall configured to regulate a position of an upstream edge, in the discharging direction, of the sheet stacked on the stacking surface, the regulating wall extending from the stacking surface toward the discharging roller in a direction intersecting the discharging direction, characterized in that the regulating wall is movably attached to the opening and closing member. a cartridge; and an apparatus main body to which the cartridge is detachably attached, the apparatus main body including: a frame in which an opening portion, through which the cartridge is attached to the apparatus main body, is formed; an opening and closing member configured to move between an open position in which the opening and closing member is opened to expose the opening portion and a closed position in which the opening and closing member is closed to cover the opening portion, the opening and closing member having a supported portion supported by the frame so that the opening and closing member is rotatable about a rotational axis, the opening and closing member having a stacking surface on which a sheet is to be stacked when the opening and closing member is located in the closed position; a discharging roller configured to discharge the sheet in a discharging direction onto the stacking surface when the opening and closing member is located in the closed position; and a regulating wall configured to regulate a position of an upstream edge, in the discharging direction, of the sheet stacked on the stacking surface, the regulating wall extending from the stacking surface toward the discharging roller in a direction intersecting the discharging direction, a frame in which an opening portion, through which the cartridge is attached to the apparatus main body, is formed; an opening and closing member configured to move between an open position in which the opening and closing member is opened to expose the opening portion and a closed position in which the opening and closing member is closed to cover the opening portion, the opening and closing member having a supported portion supported by the frame so that the opening and closing member is rotatable about a rotational axis, the opening and closing member having a stacking surface on which a sheet is to be stacked when the opening and closing member is located in the closed position; a discharging roller configured to discharge the sheet in a discharging direction onto the stacking surface when the opening and closing member is located in the closed position; and a regulating wall configured to regulate a position of an upstream edge, in the discharging direction, of the sheet stacked on the stacking surface, the regulating wall extending from the stacking surface toward the discharging roller in a direction intersecting the discharging direction, characterized in that the regulating wall is movably attached to the opening and closing member.