andrew_biggart Posted February 26, 2010 Share Posted February 26, 2010 Ok I have written this script to upload images and auto thumbnail them but i am getting the white screen i cannot spot the syntax error please help. <?php $images_location = "../Profile_pics/"; $thumbs_location = "../Profile_thumbs/"; $thumb_width = 50; $maximum_size = 5000000; $results = "Click browse to locate your profile picture!"; require ("uploader.php"); if ($_POST) { //checking for image if ($_FILES['image']['name'] == "") { $results = "Please select the image you want to upload!" ; } //start of upload else { $size = filesize($_FILES['image']['tmp_name']); $filename = stripslashes($_FILES['image']['name']); $extension = get_image_extension($filename); if($size >$maximum_size) { $results = "Your Image is to big, please selecta smaller image!"; else // allow only certain extensions if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $results = "Invalid image extension, images can only be .jpg, .jpeg, .png or .gif!"; } //generates random name else $image_random_name = random_name(15).".".$extension; $copy = @copy($_FILES['image']['tmp_name'], $images_location.$image_random_name); if (!$copy) { $results = "There was a problem uploading your image, please try again!"; else { create_thumbnail($images_location.$image_random_name,$thumbs_location.$image_random_name, $thumb_width); $results = "Your profile picture has been uploaded!"; } } } } ?> Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted February 26, 2010 Share Posted February 26, 2010 Didn't look through all your code but noticed this: if($size >$maximum_size) { $results = "Your Image is to big, please selecta smaller image!"; else Should be... if($size >$maximum_size) { $results = "Your Image is to big, please selecta smaller image!"; } else Also note, if you just use the statement else without an opening bracket, only the 1st line of code after the else is executed with the "else" conditional, everything after that 1st line is ALWAYS executed regardless of whether the if is true or false. 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.