Hey everyone, I'm trying to add a file upload script to my testimonial app ... Can someone look at this code and give me a pointer as to what I may be doing wrong ... right now, the page just returns a blank screen. Here's the code: <?php session_start(); $file_errors["0"] = "Error: A problem occurred during file upload!"; $file_errors["1"] = "Error: File ".$_FILES["picture"]["name"]." already exists"; $file_errors["2"] = "Error: Only .jpg images under 50Kb are accepted for upload"; if (isset($_SESSION['file_errors'])) { foreach ($_SESSION['file_errors'] as $error) { echo '<span style="color: red">' . $error . '</span><br>'; if((!empty($_FILES["picture"])) && ($_FILES['picture']['error'] == 1)) { //Check if the file is JPEG image and it's size is less than 50Kb $filename = basename($_FILES['picture']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["picture"]["type"] == "image/jpeg") && ($_FILES["picture"]["size"] < 50000)) { $newname = dirname(__FILE__).'/testimonials/testimonial_pics/'.$filename; if (!file_exists($newname)) { if ((move_uploaded_file($_FILES['picture']['tmp_name'],$newname))) { header('location: [URL]'); } else { echo $error; } } else { echo $error; } } else { echo $error; } } else { header('location: [URL]'); } } } ?> Code (markup): I appreciate the help.
That might be because I don't see any html form to input the the file name or any other html. If you are posting to this script from another page you need to capture the post data if((!empty($_FILES["picture"])) Is there more or is this something you just copied and thought it would work as found?