SDE,
OK, I Haven't Got a Clue!!!
Can you find anything wrong with the below code, the error currently being display, is as follows:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\Upload.php on line
59
Code:
<?php
$errors = array();
// error checking
if (empty($_FILES['file'])) {
$errors[] = 'no file uploaded';
}
if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
$errors[] = 'Possible file upload attack';
}
switch ($_FILES['file']['error'])
{
case UPLOAD_ERR_INI_SIZE:
$errors[] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
case UPLOAD_ERR_FORM_SIZE:
$errors[] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.';
case UPLOAD_ERR_PARTIAL:
$errors[] = 'The uploaded file was only partially uploaded.';
case UPLOAD_ERR_NO_FILE:
$errors[] = 'No file was uploaded.';
case UPLOAD_ERR_NO_TMP_DIR:
$errors[] = 'Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.';
case UPLOAD_ERR_CANT_WRITE:
$errors[] = 'Failed to write file to disk. Introduced in PHP 5.1.0.';
case UPLOAD_ERR_EXTENSION:
$errors[] = 'File upload stopped by extension. Introduced in PHP 5.2.0.';
}
// your error checking
if ($_FILES["file"]["type"] != "image/gif" || $_FILES["file"]["type"] != "image/jpeg") {
$errors[] = 'Wrong image format.';
}
if ($_FILES["file"]["size"] > 20000) {
$errors[] = 'File is too large.';
}
if ($count($errors)==0) {
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. ";
} else {
// add record to database
$result = mysql_query("insert into images (filename, caption) values('".$_FILES["file"]["name"]."',mysql_real_escape_string($_POST['caption'])");
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
} else {
echo "<b>Errors</b><br />";
foreach ($errors as $each) {
echo $each."<br />";
}
}
?>
Many Thanks,