PHP image uploading script won't run

Grantnozzy

New Member
I'm building a php upload script for images, and it refuses to run at all.First off, I've got a simple post form like this:\[code\] <form action="variables.php" method="post" enctype="multipart/form-data" > <p>Event title : <input type="text" name="name" required></p> <p>Description : <input type="text" name="description" required></p> <input type="file" name="file" id="file"/> <input type="submit" value="http://stackoverflow.com/questions/3654772/submit"> </form>\[/code\]This then feeds the submitted fields to "variables.php", which looks like this:\[code\] <?php require("myfunctions.php"); $title = $_POST['name']; $description =$_POST['description']; $img = $_FILES["file"]; imgput($img); generator($title, $description); ?>\[/code\]"imgput" and "generator" are functions from "myfunctions.php", but the problem isn't in "genrator", so here's what "myfunctions.php" looks like: \[code\] <?phpfunction imgput($img) { if ((($img["type"] == "image/gif") || ($img["type"] == "image/jpeg") || ($img["type"] == "image/pjpeg")) && ($img["size"] < 500000)) { if ($img["error"] > 0) { echo "Return Code: " . $img["error"] . "<br />"; } else { echo "Upload: " .$img["name"] . "<br />"; echo "Type: " . $img["type"] . "<br />"; echo "Size: " . $img["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $img["tmp_name"] . "<br />"; if (file_exists("../uploads/" . $img["name"])) { echo $img["name"] . " already exists. "; } else { move_uploaded_file($img["tmp_name"], "../uploads/" . "event1.jpg"); echo "Stored in: " . "../uploads/event1.jpg"; } } } else { echo "Invalid file"; }}?>\[/code\]Any help would be great. I tried running test echos right after "imgput" begins, but it won't even run it.
 
Back
Top