Asday Posted July 9, 2007 Share Posted July 9, 2007 I get this error: Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\uploadFile.php on line 33 when running this code: <?php if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/bmp") // || ($_FILES["file"]["type"] == "php/php") || ($_FILES["file"]["type"] == "text/plain")) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . (($_FILES["file"]["size"] / 1024) / 1024) . "MB<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br /><br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists, foof!"; echo '<a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true">Return</a>' . ' to the page you were on.'; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo 'It`s now <a href="/upload/' . $_FILES["file"]["name"] . '">here.</a> Tell your friends!<br />'; echo '<a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true">Return</a>' . ' to the page you were on.'; } } else // line 33 { echo "Sod off."; } } ?> It's probably something hideously obvious, but I can't see it. It disappears if I comment out from "else" to "}" Thanks. Link to comment https://forums.phpfreaks.com/topic/59094-solved-if-else-uploading-problem/ Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Which is line 33? Link to comment https://forums.phpfreaks.com/topic/59094-solved-if-else-uploading-problem/#findComment-293430 Share on other sites More sharing options...
Asday Posted July 9, 2007 Author Share Posted July 9, 2007 Which is line 33? Oops, sorry, fix'd. Link to comment https://forums.phpfreaks.com/topic/59094-solved-if-else-uploading-problem/#findComment-293432 Share on other sites More sharing options...
metrostars Posted July 9, 2007 Share Posted July 9, 2007 This seems to work, although I was just fiddling with the ';'s and '}'s. <?php if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/bmp") // || ($_FILES["file"]["type"] == "php/php") || ($_FILES["file"]["type"] == "text/plain")) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . (($_FILES["file"]["size"] / 1024) / 1024) . "MB<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br /><br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists, foof!"; echo '<a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true">Return</a>' . ' to the page you were on.'; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo 'It`s now <a href="/upload/' . $_FILES["file"]["name"] . '">here.</a> Tell your friends!<br />'; echo '<a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true">Return</a>' . ' to the page you were on.'; } };} else { echo "Sod off."; } ?> Link to comment https://forums.phpfreaks.com/topic/59094-solved-if-else-uploading-problem/#findComment-293434 Share on other sites More sharing options...
Asday Posted July 9, 2007 Author Share Posted July 9, 2007 This seems to work, although I was just fiddling with the ';'s and '}'s. ... Yup, that works, thanks! Link to comment https://forums.phpfreaks.com/topic/59094-solved-if-else-uploading-problem/#findComment-293440 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.