The jpg file is then dealt with using thumbnail_generator.php (a function to resize a image, the call is in this format $oldname,$newname,$width,$height.
However none of this works, I have tried debugging and have simplified alot of stuff but it still does not work, why?
Code: Select all
function add() {
if(isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($name == "") { $errors++; $errorlist .= "A game name is required.<br />"; }
if ($description == "") { $errors++; $errorlist .= "A description is required.<br />"; }
if (strlen($description) < 20) { $errors++; $errorlist .= "The description must be at least twenty letters long.<br />"; }
if ($howtoplay == "") { $errors++; $errorlist .= "A how to play is required.<br />"; }
if (strlen($howtoplay) < 20) { $errors++; $errorlist .= "The how to play must be at least twenty letters long.<br />"; }
if (!is_numeric($width)) { $errors++; $errorlist .= "The width must be a number.<br />"; }
if (!is_numeric($height)) { $errors++; $errorlist .= "The height must be a number.<br />"; }
if ($width == "") { $errors++; $errorlist .= "The swf width is required.<br />"; }
if ($height == "") { $errors++; $errorlist .= "The swf height is required.<br />"; }
if ($name == "") { $errors++; $errorlist .= "A game name is required.<br />"; }
if ($errors != 0) { echo "We encountered some problems, see below:<br>$errorlist"; die(); }
$uploaddir = '/home/.penda/pezmc/games.pezmc.com/swf/';
$uploadfile = $uploaddir . basename($_FILES['swf']['name']);
move_uploaded_file($_FILES['swf']['tmp_name'], $uploadfile);
$uploaddir = '/home/.penda/pezmc/games.pezmc.com/logos/';
$uploadfile = $uploaddir . basename($_FILES['logo']['name']);
move_uploaded_file($_FILES['swf']['tmp_name'], $uploadfile);
$shortname = str_replace(" ","", $name);
$swf = "swf/";
$swf .= basename($_FILES['swf']['name']);
$logo = "logos/";
$logo .= basename($_FILES['logo']['name']);
include("thumbnail_generator.php");
createthumb($logo,"$shortnamesmall.jpg","20","20");
createthumb($logo,"$shortname.jpg","80","80");
createthumb($logo,"$shortnamebig.jpg","300","300");
echo "Hey it all worked, <a href=\"admin.php\">Back</a>";
echo "<br>Debug";
echo $_FILES['logo']['tmp_name'];
echo "<br>";
echo $_FILES['swf']['tmp_name'];
die();
} else {
echo "<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype=\"multipart/form-data\" action=\"admin.php?do=add\" method=\"POST\">
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1048576\" />
Game Name: <input name=\"name\" type=\"text\" /><br />
Description: <textarea name=\"description\" cols=\"50\" rows=\"5\"></textarea>
<br />
How to play: <textarea name=\"howtoplay\" cols=\"50\" rows=\"5\"></textarea>
<br />
Swf file: <input name=\"swf\" type=\"file\" /><br />
Width: <input name=\"width\" type=\"text\" size=\"5\" />
<br />
Height: <input name=\"height\" type=\"text\" size=\"5\" />
<br />
Rating: <select name=\"rating\">
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
<option value=\"6\">6</option>
<option value=\"7\">7</option>
<option value=\"8\">8</option>
<option value=\"9\">9</option>
<option value=\"10\">10</option>
</select><br />
Logo 500x500 Jpg: <input name=\"logo\" type=\"file\" /><br />
<input type=\"submit\" name=\"submit\" value=\"Send File\" />
</form>";
}