• I’m a very newbie with a php, i try to modify IImagebrowser to learning….i’ve a form that send the action:

    <?php echo "<form action=\"wp-admin/upload.php?rel_path=$rel_path&amp;action=upload\"

    i have this error al the last line of the file upload.php:

    Parse error: syntax error, unexpected $end in upload.php on line 132

    <?php

    if($_REQUEST['action'] == "upload"){
    echo "<span class='highlight'>";

    //if (!get_settings('use_fileupload')){ //Checks if file upload is enabled in the config
    // echo (__("The admin disabled this function"));
    if (!current_user_can('upload_files')){
    echo(__('You do not have permission to upload files.'));
    }
    else {
    //$upl_path = get_settings('fileupload_realpath').$rel_path;
    $upl_path = ABSPATH.'/'.get_settings('upload_path').$rel_path;
    if (!is_writable($upl_path)){
    //printf(__("It doesn't look like you can use the file upload feature at this time because the directory you have specified (<code>%s</code>) doesn't appear to be writable by WordPress. Check the permissions on the directory and for typos."), get_settings('fileupload_realpath').$rel_path);
    printf(__("It doesn't look like you can use the file upload feature at this time because the directory you have specified (<code>%s</code>) doesn't appear to be writable by WordPress. Check the permissions on the directory and for typos."), ABSPATH.'/'.get_settings('upload_path').$rel_path);
    }
    else {
    $allowed_types = explode(' ', trim(strtolower($imagesallowed)));
    $img1_name = $HTTP_POST_FILES['upl_file']['name'];
    $img1 = $HTTP_POST_FILES['upl_file']['tmp_name'];

    $imgtype = explode(".",$img1_name);
    $imgtype = strtolower($imgtype[count($imgtype)-1]);
    //check that this is an image, no funnybusiness
    $checkthatimage = getimagesize($img1);
    if ($checkthatimage == FALSE) {
    unlink($img1);
    die (__("Not a valid image file."));

    }

    //end check

    if (in_array($imgtype, $allowed_types) == false) {
    echo sprintf(__('File %1$s of type %2$s is not allowed.') , $img1_name, $imgtype);
    }
    else {//file type is allowed
    if( $HTTP_POST_FILES['upl_file']['size'] > ($maxuploadsize*1024))
    echo __("File is larger than allowed limit!");
    else {//filesize is OK
    if($HTTP_POST_FILES['upl_file']['size'] > 0){//larger than 0 is allowed:o)
    ?? $pathtofile2 = $upl_path.$img1_name;
    if(file_exists($pathtofile2)){
    printf(__(“The filename ‘%s’ already exists!”), $img1_name);
    }
    else {
    //let’s move the file
    $moved = move_uploaded_file($img1, $pathtofile2);
    // if move_uploaded_file() fails, try copy()
    if (!$moved) {
    $moved = copy($img1, $pathtofile2);
    }
    if ($moved) {
    printf(__(“Couldn’t upload your file to %s.”), $pathtofile2);
    } else {
    chmod($pathtofile2, 0666);
    @unlink($img1);
    }

    }

    }//doesn’t exist
    }//>0
    }//<maxSize

    }

    }

    }
    echo “</span>”;
    }

    else {
    echo “hallo”;
    }

    ?>
    `

Viewing 5 replies - 1 through 5 (of 5 total)
  • “Parse error” is common. It’s saying that you have something (in your case, “$end”, on lone 132 of your code) that shows up when it’s not supposed to.

    Usually, it means that you’ve spelled something wrong, or put in the wrong syntax – or a more common error is that you didn’t close something that should be closed. For example, if you forgot a “;” or “}” – if one of those is missing, you’ll get this error.

    So look at line 131 and see if you’re missing a closing element or something – that’s most likely the issue.

    Make sure you’ve got the right syntax:

    <?php echo “<form action=\”wp-admin/upload.php?rel_path=$rel_path&action=upload\”;
    ?>

    Don’t forget the ; (semi-colon) at the end of the echo statement! And if you’re following it with HTML, you’ll need to close the PHP tag with ?>

    Thread Starter Marcomail

    (@marcomail)

    Maerk i’ve truncated the php function to post here, it is correct.

    The error is in the upload.php file, but i’ve copied the same function from iimagebrowser.php file…the elements are all closed correctly.

    is it possible the script can’t read this

    if($_REQUEST['action'] == "upload"){

    For the record, I got that exact same error (different line) just a moment ago while coding my PHP – it was because I was missing a closing “}”.

    Thread Starter Marcomail

    (@marcomail)

    I must add a “}” at the finish of the code ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘why this little code don’t work ??’ is closed to new replies.