David Blair Wilson, 55, attended Edinburgh Prison for a pre-arranged meeting with an inmate, Lee Brown.
He was told that his folders would have to be scanned and was asked to hand in his mobile phone.
He said he was going to put his phone back in his car and jurors saw closed circuit television footage of Blair Wilson leaning into the vehicle before returning to the reception area.
His folders were scanned and he was admitted. Later, he was detained by police after going back to the car.
Detective Constable David McAlinden told the High Court in Edinburgh that four packages were found in the driver’s footwell of the vehicle and another in the boot.
DC McAlinden said Blair Wilson’s mobile was in the car and it rang more than once displaying the name Lee Brown.
He added that the packages contained syringes, tablets and bottles.
Three mobile phones and SIM cards and chargers were also inside.
The packages had looked like white paper inside heat-sealed plastic sleeves.
“You would not know the contents unless you opened them,” said DC McAlinden.
The witness said that in CCTV footage, a package “almost identical” to those in the car could be seen in folders carried by Blair Wilson when he first arrived at the jail. However, after he had gone out to his car and returned, the folders were “considerably thinner” and the package could not be seen.
DC McAlinden stated that Lee Brown had not been among the names on Blair Wilson’s folders.
Under questioning, Blair Wilson had said that he earned £2,000 a month, but owed £5,000 to his father. He had borrowed the money while unemployed.
Blair Wilson denies attempting to introduce prohibited articles - mobile phones and drugs including cannabis resin and diazepam - into the prison on 6 October, 2011. He has blamed someone else in a special defence of incrimination.
The trial continues.