mike12255 Posted March 24, 2009 Share Posted March 24, 2009 So im trying to upload an image (exaple - schoolworkanswers.com/kaon/imges/DOGGY.jpg) but it says the file is forbidden and i think this is whats stopping me from being able to display it. All the pictures in that folder that were not uploaded using my script are not forbidden and have no problems, any suggestions??: <?php include ("connect.php"); ini_set ("display_errors", "1"); error_reporting(E_ALL); //this returns the name of the image $name = $_FILES['uploadfile']['name']; //get the extension of the image $ext = substr($name,-3); //We will add some secruity here, make sure the extension is an image file extension if($ext == "gif" || $ext == "jpg" || $ext == "png" || $ext == "peg"){ //The part the user selected to insert the image into $area = $_POST['catagory']; //get the descirption $desc = $_POST['desc']; //more security, make sure 'catagory' is actually a choice offered and not a mysql query (or something else entered) if (!in_array($area, array("Sofas","Beds and Bunks","Dressers and Cabinets","Side Tables and Desks"))) { header ("Location: index.php"); } //set vars in here $wantedname = $_POST['name']; // This is the temporary file created by PHP $uploadedfile = $_FILES['uploadfile']['tmp_name']; //below changes the files name if ($name != $wantedname){ $name = $wantedname; } list($width,$height)=getimagesize($uploadedfile); $newwidth = 100; $newheight = 100; //copy the file to were we want it now //die($name); //rename("$uploadedfile", "images/". $name .".". $ext); $copied = copy($_FILES['image']['$uploadedfile'], $name .".". $ext); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } $path = "images/" . $area . "/". $name .".". $ext; //lets put it into the database $uname = $name . "." . $ext; $sql = "INSERT INTO tbl_product (pd_name,pd_path,pd_desc,cat_name) VALUES ('$uname','$path','$desc','$area')"; mysql_query($sql) or die (mysql_error()); }else{ header ("Location: index.php"); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.