In reply to mike_uk82:
I went mid-june to mid july last year. The signs at the Yosemite National Park entrance (which is miles from the valley) all showed all campsites full. Seemingly (according to the rangers) all the sites book up within minutes of the booking website opening. Other accomodation in the valley is outrageously expensive (and also usually full). Camp 4 is the only non-bookable (walk on) site - you can only stay 7 nights maximum so at least 1/7 of the spaces come available each day. To be sure of a place you need to "wait in line", a very civilised form of queueing from about 6am, (the kiosk opens at 8.30am). Don't expect too much of camp 4, I thought it a rather squalid dump, but at least it is a cheap dump! The rangers are wise to most tricks and are pretty vigilant.
We also went to Tuolumne, that site opens 1 July but also gets very heavily booked, it has some walk on sites and each morning the board showed some vacancies but they were quickly snapped up. Once again get there early. One thing you need to know is that in the Valley and at Tuolumne the mosquitoes are grim in July and August - you can buy really strong repellent out there.
Other options: You can camp outside the park at Merced (the show ground I think), the drive each day is apparently about 40 mins each way. On the east side of the range you can camp at one of many Inyo National forest campsites which are found just over the Tioga pass from Tuolumne. These are cheap, basic and usually eary to get a place on (all are "walk in"). They allow up to 14 day stays. We camped at one beside the Tioga Pass resort, the host was very friendly but obviously smoked too much grass in the 60's! The major downside of trhis site was that it was at just under 10,000 feet and there were acclimatisation issues. The upside of camping over the Tioga is that you can go down to Lee Vining (beside the weird Mono Lake) and eat in the restaurant at the Mobil Fuel Station where the Tioga road joins the main N-S Highway - an experience not to be missed.