I cant fine this error any of you guys see it?
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home2/www/experttyping/upload.php on line 65
if (!isset ($_POST["SubmitUpload"])) {
?>
<!-- put all in upload.php file -->
<form action="upload.php" method="post" enctype="multipart/form-data">
Browse a File to Upload: <i>file must be 1MB or less. (1048576 bytes)</i><br />
<b>REMEMBER: files with an other file extension then (.doc .pdf .xls .mdb .adp .mda .zip .rtf) will be deleted!</b><br />
<input type="file" name="filetoupload"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="<?=$size_bytes; ?>">
<br>
<input type="Submit" name="SubmitUpload" value="Upload File">
</form>
<?php
/* Description -----------------------------------------------------
The Super Global Variable $FILES is used in PHP 4.x.x.
$FILES['upload']['size'] ==> Get the Size of the File in Bytes.
$FILES['upload']['tmp_name'] ==> Returns the Temporary Name of the File.
$FILES['upload']['name'] ==> Returns the Actual Name of the File.
$_FILES['upload']['type'] ==> Returns the Type of the File.
So if I filetoupload the file 'test.doc', the $FILES['upload']['name']
would be 'test.doc' and $FILES['upload']['type'] would be 'application/msword'.
---------------------------------------------------------------------*/
// this is the upload dir where files will go.
//Don't remove the /
//Chmod it (777)
$upload_dir = "upload/"; //change to whatever you want.
// files less than 1MB
$size_bytes = 1048576; //bytes will be uploaded
//check if the directory exist or not.
if (!is_dir("$upload_dir")) {
die ("The directory <b>($upload_dir)</b> doesn't exist");
}
//check if the directory is writable.
if (!is_writable("$upload_dir")){
die ("The directory <b>($upload_dir)</b> is NOT writable, Please Chmod (777)");
}
// ADDED: (Ignace Knops) if file has got an unauthorized file extension, file will not be uploaded!
$file=$_FILES['upload']['name'];
$f_types=array ("doc", "pdf", "xls", "mdb", "adp", "mda", "zip", "rtf");
$ext=substr($file,-3);
for($x=0;$x < count($f_types); $x++)
{
if($ext != $f_types[$x])
{
print "The submitted file had an unauthorized file extension, file will not be uploaded!";
exit;
}
}
//Check first if a file has been selected
//if is_uploaded_file('filename') returns true then
//a file was uploaded via HTTP POST. Returns false otherwise.
if (is_uploaded_file($_FILES['filetoupload']['tmp_name']))
{
//Get the Size of the File
$size = $_FILES['filetoupload']['size'];
//Make sure that $size is less than 1MB (1000000 bytes)
if ($size > $size_bytes)
{
echo "<div style="padding: 10px">File Too Large. Please try again.</div>"; <---this is the line
exit();
}
// $filename will hold the value of the file name submitted from the form.
// ADDED: Ignace Knops (File with spaces will now get underscores).
$filename = $FILES['filetoupload']['name'];
$filename = str_replace (" ", "", $filename);
// Check if file is Already EXISTS.
if(file_exists($upload_dir.$filename)){
echo "Oops! The file named <b>$filename</b> already exists";
exit();
}
//Move the File to the Directory of your choice
//move_filetoupload_file('filename','destination') Moves an filetoupload file to a new location.
if (move_uploaded_file($_FILES['filetoupload']['tmp_name'],$upload_dir.$filename)) {
//tell the user that the file has been filetoupload
echo "<div style="padding: 10px">Your file has been uploaded would.<br />Would you like to see all <a href="view_uploaded_files.php">uploaded files</a>?</div>";
exit();
}
else
{
//Print error
echo "<div style="padding: 10px">There was a problem moving your file</div>";
exit();
}
}
}
?>