-4
    <?php
    if(isset($_POST['submitted'])){
    if(isset($_FILES['upload'])){
       $allowed=array('image/pjepg','image/jpeg','image/JPG','image/X-PNG','image/PNG','image/png');
    if(in_array($_FILES['upload'][type],$allowed)){
    if(move_uploaded_file($_FILES['upload']['tmp_name'],"../upload/{$_FILES['upload']['name']}")){
        echo '<p><em> The file has been uploaded!</em></p>';
        }
    else {
        echo '<p class="error">Please upload a JPEG or PNG image. </p>';
    }
}
isset($_FILES['upload'])

if($_FILES['upload']['error']>0){
    echo '<p class="error">The file could not be uploaded because: <strong>';

    switch ($_FILES['upload']['error']) {
        case 1:
            print 'the file exceeds the upload_max_filesize setting in php.ini.';
            break;
        case 2:
            print 'the file exceeds the MAX_FILE_SIZE setting in HTML form.';
            break;
        case 3:
            print 'the file was only partially uploaded.';
            break;
        case 4:
            print 'No file was uploaded.';
            break;
        case 5:
            print 'No temporary folder was availiable.';
            break;
        case 6:
            print 'Unable to write to the disk.';
            break;
        case 7: 
            print 'File uploaded stopped.';
            break;
            default:
            print 'A system error occurred.';
            break;
        }

        print '</strong></p>';
    }
  if((file_exists($_FILES['upload']['tmp_name'])) && (is_file($_FILES['upload']['tmp_name']))){
    unlink($_FILES['upload']['tmp_name']);
    }
}

?>

when i run this i get:

Parse error: syntax error, unexpected T_IF in C:\wamp\www\project\uploadctrl.php on line 15

and i cant find any errors in syntax..i search everything on code but i didnt find anything..anyone can help???

4
  • 1
    Missing ; after isset($_FILES['upload']). Commented May 9, 2012 at 20:18
  • 2
    You should remove isset($_FILES['upload']) instead of adding a semi-colon since it doesn't do anything but waste cycles on an unused conditional. Commented May 9, 2012 at 20:19
  • OP, your first ten lines or so really could use some indentation - it is hard for you (or anyone) to see what braces match up at the moment. Also: if you're wondering why you're getting downvotes, it's not because of the error itself - it's because you haven't explained what you've already tried to fix it. Commented May 9, 2012 at 20:22
  • possible duplicate of Parse error: syntax error, unexpected T_IF - And please learn how to debug syntax errors in PHP. Install the latest PHP 5.4 version which gives better error messages to locate causes of syntax-errors. Also an IDE like PHPStorm can help you to highlight the cause of an error while you type. Commented May 10, 2012 at 7:55

1 Answer 1

1

Your:

isset($_FILES['upload'])

needs to be:

isset($_FILES['upload']);

It does say line 15, usually error lies just before that line.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.