Page 1 of 1

What is wrong.....

Posted: Mon Mar 21, 2005 7:41 am
by phelpsa
....with this code??

It says there is a parse error in line 52???

Code: Select all

<html>
<head>
    <title>Uploading.....</title>
</head>
<body>
<h1>Uploading Picture</h1>
<?php

    if ($_FILES['userfile']['error'] > 0)
    {
       echo 'Problem:  ';
       switch ($_FILES['userfile']['error'])
       {
        case 1:   echo 'File exceeded upload_max_filesize'; break;
        case 2:   echo 'File exceeded max_file_size'; break;
        case 3:   echo 'File only partially uploaded'; break;
        case 4:   echo 'No file uploaded'; break;
       }
       exit;
    }

//put the file where we'd like it
$upfile = '/uploads/'.$_FILES['userfile']['name'] ;

if (is_uploaded_file($_FILES['userfile']['tmpname']))
{
   if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile))
    {
       echo 'Problem: Could not move file to directory';
       exit;
    }
}
else
{
   echo 'Problem: Possible file upload attack. Filename: ';
   echo $_FILES['userfile']['name'];
   exit;

echo 'File uploaded successfully<br><br>';

//reformat the file contents
$fp = fopen($upfile, 'r');
$contents = fread ($fp, filesize ($upfile));
fclose ($fp);

//show what was uploaded
echo 'Preview of upload';
echo $contents;
echo '<br><hr>';
?>
</body>
</html>

feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon Mar 21, 2005 7:46 am
by CoderGoblin

Code: Select all

else
{
   echo 'Problem: Possible file upload attack. Filename: ';
   echo $_FILES['userfile']['name'];
   exit;
You do not close this.

Posted: Mon Mar 21, 2005 7:59 am
by feyd
phelpsa, please work on coming up with decent topic titles... thanks.