Tim Brown, a Network Rail employee, captured the image at Trowbridge station, Wiltshire, on Saturday afternoon.
The photo, which went on viral on social media, shows the child peering over the platform as his father and two young girls stand close by.
Mr Brown, 44, from Great Barr in Birmingham posted the image on Facebook with the comment: “Absolutely unbelievable.
“Spoke to the ‘Adult’, his reply was ‘the train’s not due’.
“When I pointed out there may be others (for example) freight, empties, unscheduled etc, the reply was ‘the next ones not till 1638’.
“After speaking to the guard and explaining to the man that people are seriously injured and die doing this I was told (by the not so responsible adult) I was a do-gooder and the lad just wanted to look at the track.
“I can only try.”
The boy’s father Ian Stanton is reportedly due to talk to the British Transport Police, who have said in a statement: “Officers have been made aware of a photograph on social media which show a child in a dangerous position on the platform of Trowbridge station.”
It adds: “We are making enquiries into this incident as part of an investigation.
“No arrests have been made.”
Mr Stanton, 46, has defended his actions and told the BBC his son was never in danger.
He said: “We were on our way to the Bath Carnival and our train was delayed.
“Devon is quite an inquisitive kid and wanted to pick up a stone or piece of wood from the track as treasure.
“I told him it wasn’t a good idea and then he asked if he could have a quick look.”
He added that he was “standing right by” his son who was only leaning over the platform for “all of 30 seconds”.
After Mr Brown’s photo appeared online, social media users expressed their despair at Mr Stanton’s behaviour.
Veronica Greenhouse wrote: “I would be having kittens and dragging (the) boy away by his ankles.
“Better gravel rash and grazes than no head.”
Iris Daws: “Some people are so stupid, they don’t realise how dangerous train stations can be, I’ve seen a boy die on a railway station once.
“If that man had seen what I’ve seen, he wouldn’t be letting that child do this.”
A spokesman from Great Western Railway, which managers Trowbridge railway station, said: “Trains often pass through railway stations without stopping and without appearing on any timetable at very high speeds.
“Stay safe by keeping back from the platform edge and behind the yellow at all times, and listen out for announcements.”