Hi all

This simple application is for 3 companies I deal with. Signwriter, printer
and architect. The brief was to give them a simple page which will allow
their clients to upload artwork without messing around with ftp.

As you can see there is nothing earth shattering about it, the big thing was
the large file upload. I've tested with just under 90megs and that went
through ok.

I'm going to tart it up some more, probably rejecting scripts, exes, dlls
before giving it the graphics people to make it look pretty.

The pages are hosted on a linux server.


The html form
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="default.css" rel="stylesheet" type="text/css" />
<script language="Javascript">
function submitme(){
cMess="";
oform=document.forms[0];
if(oform.fldpname.value==""){
   cMess="Please enter your Project Name";
}
if(oform.fldname.value==""){
   cMess="Please enter your Name";
}
if(oform.fldphone.value==""){
   cMess="Please enter your Telephone Number";
}
if(oform.fldemail.value==""){
   cMess="Please enter your Email Address";
}
if(cMess!=""){
  alert(cMess);
  return false;
}
else{
  oform.submit();
}

}
</script>

</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="104857600" />
<input type="hidden" name="POST_MAX_SIZE" value="104857600" />
<table width=100%>
<tr><td><img src="./images/logo.gif"></td></tr>
</table>
<span class="title">Client Upload Area</span>
<br><br>
<span class="smalltitle">Format:</span>
<ul><li>No MAC files!</li>
<li>All files must be sent with CMYK-colour settings.</li>
<li>Use the following formats only: JPEG, PDF.</li>
<li>With vector graphic formats all text must be converted to paths!</li>
<li>Set up pixel images with 300 dpi to avoid loss of quality during
printing.</li>
<li>All text, logos, and important artwork must stay away from all edges by
a minimum of 5mm to avoid being cut off. </li>
</ul>

<table border=0px>
<tr><td colspan=2>Please enter your details in the spaces below</td>
<td style="border: 1px solid gray" rowspan=12>Some nice adverts can go in
here</td>
</tr>
<tr>
<td>Enter Project Name:</td>
<td><input type="text" name="fldpname" size=75></td>
</tr>
<tr>
<td>Your Name:</td>
<td><input type="text" name="fldname" size=75></td>
</tr>
<tr>
<td>Your Company Name:</td>
<td><input type="text" name="fldcname" size=75></td>
</tr>
<tr>
<td valign="top">Your Address:</td>
<td><input type="text" name="fldadd1" size=75><br>
<input type=text name=fldadd2 size=75><br>
<input type=text name=fldadd3 size=75><br>
<input type=text name=fldadd4 size=75><br>
<input type=text name=fldadd5 size=75><br>
</td>
</tr>
<tr>
<td valign="top">Your Telephone Number:</td>
<td><input type=text name=fldphone size=75></td>
</tr>
<tr>
<td valign="top">Your Fax Number:</td>
<td><input type=text name=fldfax size=75></td>
</tr>
<tr>
<td valign="top">Your Email Address:</td>
<td><input type=text name=fldemail size=75></td>
</tr>
<tr>
<td valign="top">How can we help?:</td>
<td><textarea rows=10 name=fldcomments cols=75></textarea></td>
</tr>

<tr><td>

    Choose a file to upload: </td><td><input name="uploaded_file"
type="file" />
</td></tr>
<tr><td colspan=3><input type="button" value="Upload" onclick="submitme()"
/></td></tr>

</form>
</body>
</html>


css

body
{
        font-family: "Helvetica Neue", Helvetica, sans-serif;
        border: 1px solid #ff0000;
        padding: 0px;
        margin: 0px;
}

span.title
{
        font-family: "Helvetica Neue", Helvetica, sans-serif;
        font-size:40px;
        font-weight:bold;
        color:blue;
        padding: 0px;
        margin: 0px;
}

span.smalltitle
{
        font-family: "Helvetica Neue", Helvetica, sans-serif;
        font-size:20px;
        font-weight:bold;
        color:blue;
        padding: 0px;
        margin: 0px;
}
PHP.Ini needs to be in the root of the webspace.


max_execution_time=1200
max_input_time=1200
memory_limit=100M
post_max_size=100M
upload_max_filesize=100M
max_file_size=104857600
post_max_size=104857600
This is the upload file


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="default.css" rel="stylesheet" type="text/css" />
<body>
<table width=100%>
<tr><td><img src="./images/logo.gif"></td></tr>
</table>
<span class="title">Client Upload Area</span>
<br><br>
<table border=0px>
<tr><td colspan=2>Upload Status.</td>
<td style="border: 1px solid gray" rowspan=2>Some nice adverts can go in
here</td>
</tr>
<tr><td>

<?php

if((!empty($_FILES["uploaded_file"])) ) {
  $filename = basename($_FILES['uploaded_file']['name']);
  $ext = substr($filename, strrpos($filename, '.') + 1);
  //Determine the path to which we want to save this file
  $newname = dirname(__FILE__).'/upload/'.$filename;
  //Check if the file with the same name is already exists on the server
  if (!file_exists($newname)) {
    //Attempt to move the uploaded file to it's new place
    if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname)))
{
       echo "File " . $filename ." has been succcessfully transferred.<br>
";
       echo "An email confirmation has also been sent to: " .
$_POST['fldemail'];
       if (isset($_POST['fldcname']))
       {
         //check if the email address is invalid
         $mailcheck = spamcheck($_POST['fldemail']);
         if ($mailcheck==false)
         {
            $email="[EMAIL PROTECTED]";
            $subject="File Uploaded";
            $message="File uploaded from the website:\n\n";
            $message=$message . "Project Name: ". $_POST['fldpname'] . "\n";
            $message=$message . "Contact Name: ". $_POST['fldname'] . "\n";
            $message=$message . "Company Name: ". $_POST['fldcname'] . "\n";
            $message=$message . "Address:\n". $_POST['fldadd1'] . "\n";
            $message=$message . $_POST['fldadd2'] . "\n";
            $message=$message . $_POST['fldadd3'] . "\n";
            $message=$message . $_POST['fldadd4'] . "\n";
            $message=$message . $_POST['fldadd5'] . "\n\n";
            $message=$message . "Phone: ". $_POST['fldphone'] . "\n";
            $message=$message . "Fax: ". $_POST['fldfax'] . "\n";
            $message=$message . "Email: ". $_POST['fldemail'] . "\n\n";
            $message=$message . "Comments:\n". $_POST['fldcomments'] . "\n\n";
            $message=$message . "The original filename was ". $filename . " and 
has
been saved to ". $newname . "\n";
            $email_from="[EMAIL PROTECTED]";

            mail($email, $subject,$message, "From: $email_from\r\nCC:
$email_from" );
            $conf=$_POST['fldname'] . "\nWe have received your file and will
contact you shortly to discuss. If you have any questions in the meantime
please contact Yvonne on 01332.";
            $conf=$conf. "\n\nBest wishes\nGraphics Ltd.";

            mail($_POST['fldemail'],"Thankyou for using our upload
service",$conf,"From: $email_from\r\nCC: $email_from" );

         }
       }


    }
    else
    {
      echo "Error: A problem occurred during file upload!";
    }
  } else
  {
      echo "Error: File ".$_FILES["uploaded_file"]["name"]." already
exists";
  }
} else
{
  $message="";

  $message=$message . "Project Name: ". $_POST['fldpname'] . "\n";
  $message=$message . "Contact Name: ". $_POST['fldname'] . "\n";
  $message=$message . "Company Name: ". $_POST['fldcname'] . "\n";
  $message=$message . "Address:\n". $_POST['fldadd1'] . "\n";
  $message=$message . $_POST['fldadd2'] . "\n";
  $message=$message . $_POST['fldadd3'] . "\n";
  $message=$message . $_POST['fldadd4'] . "\n";
  $message=$message . $_POST['fldadd5'] . "\n\n";
  $message=$message . "Phone: ". $_POST['fldphone'] . "\n";
  $message=$message . "Fax: ". $_POST['fldfax'] . "\n";
  $message=$message . "Email: ". $_POST['fldemail'] . "\n\n";
  $message=$message . "Comments:\n". $_POST['fldcomments'] . "\n\n";
  $message=$message . "The original filename was ".
$_FILES["uploaded_file"]["name"] . "\n";

  $email_from="[EMAIL PROTECTED]";
  mail("[EMAIL PROTECTED]","Transfer failed",$message,"From:
$email_from\r\nCC: $email_from" );

  echo "<br><br>Error: No file uploaded";
  echo "The error returned was ";
  echo $_FILES['uploaded_file']['error'];

}
?>
</td>
</tr>
</table>
</body>
</html>

<?php
function spamcheck($field)
  {
  if(eregi("to:",$field) || eregi("cc:",$field))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

?>



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to