Most, if not all, dvd/cd drives have lugs in the tray to hold the disk in place if you use it on it's side, but I wouldn't want to try it. If this is a long term plan, then you could transfer all the components to a new case. The job is within the capabilities of a competent diyer, and need not be too expensive click here.
Assuming the box is stable on its end it should be OK, most CD/DVD drive shelves have locating lugs for the disk and will work OK upright. Do remember to make sure the PSU and fan end up at the top or you could end up trapping the hot air in the box and cooking things.
Some desktop cases have enough room to turn the optical drive round so it's still the right way up, if not you may just have to keep a finger on the CD/DVDs as you push the tray back in, as despite the claims above about lugs to hold the disks I've just check a few in my office and they're not there. Possibly shave about a 1/10th of a penny doing away with them...
if you do put it under the desk, try to keep it clear of the floor; they are pretty effective at sucking up dust and fluff. Also make sure it's not likely to be kicked or rammed by a wheeled office chair; hard drives aren't fond of this kind of abuse.
I also checked, six different drives, all different makes, all had them. Look for a small raised hooked section at the rim of the CD area on the tray, usually two front and two back, just enough to hold the disk in situ when mounted vertically. Some old ones used to have an offset swivel part that you could rotate to ensure safe location, those have all gone.
This thread is now locked and can not be replied to.