Michael.
My guess is that upload is still in progress at the time your code is calling for the fclose()
Maybe change upload to a function or have it return a value and check that the upload has completed before issuing the fclose()
HTH
Ron.
Ron Seidl
Independent Developer
VFP
"I'm playing in life's theater in anticipation of a great cast party!"