I have a problem that is probably very easy to solve for someone who knows PHP, and I feel sick for 3 days. Namely, it is a Facebook application for the a photo contest, and when the user is uploading an image, the image uploading, but ejects the following error appears:

The url you supplied is invalid Warning: Cannot modify header information - headers already sent by (output started at /home/explorer/public_html/secure/foto/libs/upload/save.php:77) in /home/explorer/public_html/secure/foto/libs/upload/save.php on line 88

The URL you supplied is invalid:

Warning: Cannot modify header information - headers already sent by (output started at /home/explorer/public_html/secure/foto/libs/upload/save.php:77) in /home/explorer/public_html/secure/foto/libs/upload/save.php on line 88

Part of code: line 81-100
http://pastebin.com/MeSk4hXR

Please Help