The bug which is racking my brain is as follows.

[example code]

move_uploaded_file(temp,new)
copy(new,copy1)
copy(new,copy2)

function resize(file_name,width){
//resizes image
}
resize(copy1,500)
resize(copy2,200)

the bug i get with the code above is that when i dont run the function and the page is loaded, all 3 images are uploaded (but of course not resized.)

and when i run the code with the function the code doesnt upload and copy the files before the function runs giving me the error that the source image for the resizing is incorrect. I have run various tests and found that its nothing to do with the source file name and wondered if anyone has ever come across this and more importantly a solution or a work around.

Thanks to anyone who can help.