I'm a beginner in php this is my upload form which uses php_self..
there's a parse erro in line 33...... which is I don't know why...
can anyone help me

<?php


$target="upload/";
$basename=basename($_FILES["file"]["name"]);
$target=$target . basename($_FILES["file"]["name"]);


if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{

echo "Upload: " . $_FILES["file"]["name"] . "<br />";
// echo "Type: " . $_FILES["file"]["type"] . "<br />";
// echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
// echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";


if (file_exists( "upload/" . @$_FILES["file"]["name"]))

{
echo $_FILES["file"]["name"] . " already exists. ";
echo "</br>link:<a href='upload/$basename'>$basename</a>";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"])

echo 'upload/' . $_FILES["file"]["name"];
//echo "<a href='upload/$basename'>$basename</a>";
echo "Stored in: ".realpath('upload/'. $_FILES["file"]["name"]);
//echo "</br>link:<a href=http://localhost/stored1/upload/>$name</a>";
//echo "</br> linkinfo:" .linkinfo('upload/'. $_FILES["file"]["name"]);
//echo "</br> <a href='upload/$basename'>$basename</a>";
echo " </br>Upload Sucessfull";
}

}
else
{
echo "Invalid file";
}
//echo "<a href='upload/$basename'>$basename</a>";

?>


<html>
<body>
<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER; ?>">

<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>

1) Your move_uploaded_file() need semicolon at the end
2) your last else( for invalid file message) is without if

<?php


$target="upload/";
$basename=basename($_FILES["file"]["name"]);
$target=$target . basename($_FILES["file"]["name"]);


if ($_FILES["file"]["error"] > 0)
{
	echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{

echo "Upload: " . $_FILES["file"]["name"] . "<br />";
// echo "Type: " . $_FILES["file"]["type"] . "<br />";
// echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
// echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";


if (file_exists( "upload/" . @$_FILES["file"]["name"]))

{
echo $_FILES["file"]["name"] . " already exists. ";
echo "</br>link:<a href='upload/$basename'>$basename</a>"; 
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"])

type semicolon here

echo 'upload/' . $_FILES["file"]["name"];
//echo "<a href='upload/$basename'>$basename</a>";
echo "Stored in: ".realpath('upload/'. $_FILES["file"]["name"]);
//echo "</br>link:<a href=http://localhost/stored1/upload/>$name</a>";
//echo "</br> linkinfo:" .linkinfo('upload/'. $_FILES["file"]["name"]);
//echo "</br> <a href='upload/$basename'>$basename</a>";
echo " </br>Upload Sucessfull";
}

}

following else is witout if

else
{
echo "Invalid file";
}
[/b]
//echo "<a href='upload/$basename'>$basename</a>";

?>




<html>
<body>
<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> 
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.