Daney11 Posted February 15, 2008 Share Posted February 15, 2008 <?php if (isset($_POST['submitted'])) { // Start File Upload if (isset($_FILES['upload'])) { $allowed = array('image/gif'); if (in_array($_FILES['upload']['type'], $allowed)) { if (move_uploaded_file($_FILES['upload']['tmp_name'], "news_images/{$_FILES['upload']['name']}")) { echo "Uploaded!"; } else { echo 'Not Uploaded!'; switch ($_FILES['upload']['error']) { case 1: print 'Files Exceeds.'; break; case 2: print 'Max File HTML'; break; case 3: print 'No File Uploaded'; break; case 4: print 'No Folder'; break; case 6: print 'System Error'; break; default: print "System Error"; break; } } else { echo "Wrong Type"; unlink($_FILES['upload']['tmp_name']); } } else { echo "Smaller Image"; } } // End File Upload ?> Hey guys, i get this error Parse error: parse error, unexpected T_ELSE in D:\server\www\upload1.php on line 37 line 37 being } else { Any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
rameshfaj Posted February 15, 2008 Share Posted February 15, 2008 Such a simple question to ask in the forum.Dont you know that an else should have the corresponding if statement. I found a missing brace in the code you provided. Here is the code that I think works: <?php if (isset($_POST['submitted'])) { // Start File Upload if (isset($_FILES['upload'])) { $allowed = array('image/gif'); if (in_array($_FILES['upload']['type'], $allowed)) { if (move_uploaded_file($_FILES['upload']['tmp_name'], "news_images/{$_FILES['upload']['name']}")) { echo "Uploaded!"; } else { echo 'Not Uploaded!'; switch ($_FILES['upload']['error']) { case 1: print 'Files Exceeds.'; break; case 2: print 'Max File HTML'; break; case 3: print 'No File Uploaded'; break; case 4: print 'No Folder'; break; case 6: print 'System Error'; break; default: print "System Error"; break; } } } else { echo "Wrong Type"; unlink($_FILES['upload']['tmp_name']); } } else { echo "Smaller Image"; } } // End File Upload ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.