What exactly doesn't work? Is it just that it doesn't upload, or does it give a warning somewhere? In the fist case, could you check if the the necessary part of the script is actually reached? (Place echo "hello"; In one of the if parts.)