Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:44:51+00:00 2026-06-14T20:44:51+00:00

there is a little form on one page which has the code below, <div

  • 0

there is a little form on one page which has the code below,

<div class="postcomment">
<form id="comments" action="insertcomment.php" method="POST" enctype="multipart/form-data">
Comment: <input type="text" name="comment" id="commentfield">
<input type="submit" name="submit" value="Post comment" class="button">
<br>
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
Image: <input type="file" name="image" />
<br>
</div>

once the user adds the picture by browsing for it the form then goes to the insertcomment.php code which is below

$target_path = "images/";

$file_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $file_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

and for some reason it is displaying the error and not showing in the images directory, the error is: Parse error: syntax error, unexpected T_IF in /homepages/21/d417005970/htdocs/rk8479/htdocs/insertcomment.php on line 18

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:44:52+00:00Added an answer on June 14, 2026 at 8:44 pm

    Try this
    HTML

    <div class="postcomment">
    <form id="comments" action="insertcomment.php" method="POST" enctype="multipart/form-data">
    Comment: <input type="text" name="comment" id="commentfield">
    <br>
    Image: <input type="file" name="image" />
    <br>
    <input type="submit" name="submit" value="Post comment" class="button">
    </form>
    </div>
    

    PHP CODE (you are trying to use it on same page you can check for if(isset($_POST[‘submit’]))

    if($_FILES['image']['size'] > 0){
            $allowedExts = array("jpg", "jpeg", "gif", "png");
            $extension = end(explode(".", $_FILES["image"]["name"]));
            if ((($_FILES["image"]["type"] == "image/gif")
            || ($_FILES["image"]["type"] == "image/jpeg")
            || ($_FILES["new_image"]["type"] == "image/png")
            || ($_FILES["image"]["type"] == "image/pjpeg"))
            && ($_FILES["image"]["size"] < 1048576)
            && in_array($extension, $allowedExts))
              {
              if ($_FILES["image"]["error"] > 0)
                {
                $error_message = $_FILES["image"]["error"];
                }
              else
                {
    
                if (file_exists("images/" . $_FILES["image"]["name"]))
                  {
                  $error_message = $_FILES["image"]["name"] . " " . $LANG['image_exist'];
                  }
                else
                  {
                  if(move_uploaded_file($_FILES["image"]["tmp_name"],
                  "images/" . $_FILES["image"]["name"])) {  
                  // success
                  $image_name = $_FILES["image"]["name"];
                  } else {
                  $error_message = "Upload Failed!";
                  }
                  }
                }
              }
            else
              {
              $error_message = "Error: May be different ext or size";
              }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got my little mechanize code: br.open('http://tumblr.com/customize'); print br.response().read() print br.form['edit_tumblelog[cname]'] # there definitely is
There is very little code out there that is in VB, and i'm getting
I've been working with pthreads a fair bit recently and there's one little thing
Link: http://hedenstedfotoklub.net.dynamicweb.dk/ In the upper grey area there is a little icon which triggers
There's a blog post comment on codinghorror.com by Paul Jungwirth which includes a little
I have a database that has two tables, one of which contains a foreign
I'm working on a simple one-page calculator, heavy with JavaScript and form elements. Here
I've built a little app with models Page and Mark . Mark also has
There is little documentation on how to use the low level api for datastore
I'm developing a ASP.NET MVC application. There is little space for me to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.