File: /home/awaldron/www/archive/demo/upload/index.php
<?php
session_start();
?>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html><head>
<title>Vocollect Inc. : Photo Upload</title>
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<script language="JavaScript1.2">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function uploadFile(ext) {
var ftype = ext.value.lastIndexOf(".");
if ((ftype == ".jpg") || (ftype == ".JPG")) {
disableButton();
return FALSE;
} else {
alert("The file you've chosen is not a valid image filetype. Please upload only JPEG images.");
document.fupload.reset();
return FALSE;
}
}
function disableButton() {
document.fupload.upload.value='File Upload in Progress, Please Wait...';
document.fupload.upload.disabled=true;
}
//-->
</script>
</head>
<body style="margin:5px;">
<link rel="stylesheet" type="text/css" href="/default.css">
<div align="center">
<?php
include("functions.php");
include("../_functions.php");
require("uplConfig.php");
dbconnect();
if ($_GET["a"]=="doc") echo "<div id=\"heading\">File Upload</div>\n";
else echo "<div id=\"heading\">Photo Upload</div>\n";
echo "<div id=\"box\">\n";
// start of upload script
if ($submit != "yes") { // case upload button was not pressed yet
echo "<table border=0>\n";
echo "<form name=\"fupload\" action=\"index.php?a=".$_GET["a"]."\" method=\"post\" enctype=\"multipart/form-data\">";
//if ($_GET["a"]=="doc") echo " onSubmit=\"return disableButton();\">\n";
//else echo " onSubmit=\"return uploadFile();\">\n";
echo "<input type=\"hidden\" name=\"submit\" value=\"yes\">\n";
if ($_GET["a"]=="photo") {
echo "<input type=\"hidden\" name=\"gennewname0\" value=\"".(isset($_GET["fn"])?$_GET["fn"]:$_SESSION['auth_user']).".jpg\">\n";
echo "<input type=\"hidden\" name=\"fileexists0\" value=\"overwrite\">\n";
echo "<tr><td> </td></tr>\n";
echo "<tr><td><b>Rule 1:</b> Photo can only be of type JPEG with a .jpg extension</td></tr>\n";
echo "<tr><td><b>Rule 2:</b> Photo cannot have a filesize larger than 1 MB</td></tr>\n";
echo "<tr><td> </td></tr>\n";
echo "<tr><td>** Recommended photo dimensions are 200px high and 160px wide.</td></tr>\n";
} else if ($_GET["a"]=="content") {
echo "<input type=\"hidden\" name=\"fileexists0\" value=\"autorename\">\n";
echo "<tr><td> </td></tr>\n";
echo "<tr><td><b>Please Note!</b> Image cannot have a filesize larger than 2 MB</td></tr>\n";
} else if ($_GET["a"]=="doc") {
echo "<input type=\"hidden\" name=\"fileexists0\" value=\"autorename\">\n";
echo "<tr><td> </td></tr>\n";
echo "<tr><td><b>Please Note!</b> File cannot have a filesize larger than 25 MB</td></tr>\n";
}
echo "<tr><td> </td></tr>\n";
echo "<tr><td>Use the Browse Button to select the file you wish to upload:</td></tr>\n";
echo "<tr><td><input type=\"file\" name=\"file2upl[]\" size=\"36\"></td></tr>\n";
if ($_GET["a"]=="doc") echo "<tr><td><br>Title of File/Document: <i>(optional)</i><br><input type=\"text\" name=\"doctitle\" size=\"50\"></td></tr>\n";
echo "<tr><td><input type=\"submit\" name=\"upload\" value=\"Upload File\"></td></tr>\n";
echo "<tr><td> </td></tr>\n";
echo "<tr><td><b>Please Note:</b> Depending on the size of your file and your internet's connection speed, your upload may take several minutes. This window will close when the upload is complete.</td></tr>\n";
echo "<tr><td> </td></tr>\n";
echo "</form>\n";
echo "</table>\n";
} else { // upload button was pressed; process upload
echo "<center><br><br>\n";
$fn = upload($_FILES);
if ($fn === FALSE) {
echo "<br><br><br>";
} else if ($_GET["a"] == "photo") {
echo "<script><!--\n";
echo "window.opener.location.reload();\n";
echo "window.close();\n";
echo "//--></script>\n";
} else if ($_GET["a"] == "content") {
echo "<b>Photo Upload Successful!</b>\n";
echo "<br><br><br>Copy & Paste the code below into the<br>Page Body text area of the Edit Content page.\n";
echo "<P><textarea style=\"height:34px;width:565px;padding:10px;text-align:center;\">[img]/gui/pics/".$fn."[/img]</textarea></center><br><br><br>\n";
} else if ($_GET["a"] == "doc") {
echo "<b>Document Upload Successful!</b>\n";
echo "<br><br><br>Copy & Paste your desired piece of code below into the<br>Page Body text area of the Edit Content page.\n";
if (($_POST["doctitle"] == "") || !isset($_POST["doctitle"])) echo "<P><textarea style=\"height:34px;width:565px;padding:10px;text-align:center;\">[url]/files/".$fn."[/url]</textarea></center><br><br><br>\n";
else echo "<P><textarea style=\"height:70px;width:565px;padding:10px;text-align:center;\">[url=/files/".$fn."]".$_POST["doctitle"]."[/url]</textarea></center><br><br><br>\n";
}
} // end else
?>
<?php
echo "</div>\n";
?>
</div>
</body></html>