codeline Posted August 20, 2010 Share Posted August 20, 2010 Going to try and explain this the best I can but I don't really have the best idea on what's happening here. I have a submission form for users to fill out their information and upload an image. I've set the file limit size at 500000 which I assumed would be safe for images at 400k or below. When testing locally, any image that is below that file size gets uploaded successfully. However, when testing on my online host/server.. the submission form and data is successfully entered but the image isn't saved at all. It obviously isn't over the size of the file limit I set because it dooesn't return an error.. it successfuly submits but doesn't save or resize my image. I really have no clue what the problem could be. I went over the variables I set for folder locations to move the image to and everything works fine locally, but once on the host and online, it doesn't happen. Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 20, 2010 Share Posted August 20, 2010 Hi Is the image never saved? Have you tried it with a small image? If it never saves then I would guess that you are trying to pick it up from an incorrect location when online (ie the tmp_name) or that your script doesn't have permission to write to the final location you are copying the files to. All the best Keith Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 Hmm, just tried a 98 k image and the image wasn't even saved. I checked the folder where it should be stored and it wasn't located. So I'm thinking locally, the variables I have with the new locations for the image are being read properly, but online, the paths aren't reading correctly. Any advice on how I can figure this out? I checked parent folders and didn't notice any directories being made either. Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 Here's the code that is identical both locally and online: A few other things that I believe might cause a problem.. I've got .htaccess with cleaner URLs so my pages don't have the .php extension. if(!empty($_POST['submitFeature'])) { // set variables $featurename = mysql_real_escape_string($_POST['featurename']); $featuredesc = mysql_real_escape_string($_POST['featuredesc']); $name = mysql_real_escape_string($_POST['name']); $email = mysql_real_escape_string($_POST['email']); $email2 = mysql_real_escape_string($_POST['email2']); $age = mysql_real_escape_string($_POST['age']); $city = mysql_real_escape_string($_POST['city']); $state = mysql_real_escape_string($_POST['state']); $src = $_FILES['featureupload']['tmp_name']; $featuresize = $_FILES['featureupload']['size']; $limitsize = 500000; // 1 - A. REQUIRED FIELDS VERIFICATION if(!empty($featurename) && !empty($name) && !empty($email) && !empty($email2) && !empty($city) && !empty($state) && ($email == $email2) && !empty($_FILES['featureupload']['tmp_name']) && ($featuresize < $limitsize)) { // 2 - A. SANITIZE AND VALIDATE EMAIL $email = filter_var($email, FILTER_SANITIZE_EMAIL); if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { print ' <ul class="errorlist"> <li class="alert">Error!</li> <li>Invalid Email Address</li> </ul> '; } else { // 3 - A. VALIDATE IMAGE EXTENSION // verify that image uploaded is proper extension $fname = strtolower($_FILES['featureupload']['name']); // grab uploaded image's filename and lowercase the extension (ex: .JPG) if(preg_match('/[.](jpg)|(gif)|(png)$/', $fname)) { // set image variables $path_image = 'submissions/'; $final_width_of_image = 550; $randomappend=rand(0000,9999); // generate random number to append to filename $src = $_FILES['featureupload']['tmp_name']; // grab the src for where the image is temporarily held $filefull = $randomappend . $fname; // initiate new file name for submission's full image $target = $path_image . $filefull; // set variable for submission image's new location with appended name $path_image_thumb = 'submissions/thumbs/'; $final_width_of_thumb = 166; $final_height_of_thumb = 120; $filethumb = $randomappend . $fname; // initiate new file name for submission's thumbnail $target_thumb = $path_image_thumb . $filethumb; // set variable for thumbnail's new location with appended name move_uploaded_file($src, $target); if(preg_match('/[.](jpg)$/', $filefull)){ $img = imagecreatefromjpeg($path_image . $filefull); } else if (preg_match('/[.](gif)$/', $filefull)){ $img = imagecreatefromgif($path_image . $filefull); } else if (preg_match('/[.](png)$/', $filefull)){ $img = imagecreatefrompng($path_image . $filefull); } // FULL SIZE IMAGE $ox = imagesx($img); $oy = imagesy($img); $imgx = $final_width_of_image; $imgy = floor($oy * ($final_width_of_image / $ox)); $imgm = imagecreatetruecolor($imgx, $imgy); imagecopyresampled($imgm, $img, 0,0,0,0,$imgx,$imgy,$ox,$oy); if(!file_exists($path_image)){ if(!mkdir($path_image)){ die("There was a problem."); } } imagejpeg($imgm, $path_image . $filefull, 80); // END FULL SIZE IMAGE // THUMBNAIL $tox = imagesx($img); $toy = imagesy($img); $tx = $final_width_of_thumb; $ty = $final_height_of_thumb; $tm = imagecreatetruecolor($tx, $ty); imagecopyresampled($tm, $img, 0,0,0,0,$tx,$ty,$tox,$toy); if(!file_exists($path_image_thumb)){ if(!mkdir($path_image_thumb)){ die("There was a problem."); } } imagejpeg($tm, $path_image_thumb . $filethumb, 80); // END THUMBNAIL // query the actual post forms $q = "INSERT INTO submissions (id, name, age, email, city, state, country, featurename, featuredesc, featureimg, featurethumb, postdate, approved) VALUES ('', '$name', '$age', '$email', '$city', '$state', '', '$featurename', '$featuredesc', '$target', '$target_thumb', NOW(), 'NO')"; $r = mysql_query($q); if($r) { echo '<script language="JavaScript">'; echo 'alert("Successfully added a submission.")'; echo '</script>'; } else { echo '<script language="JavaScript">'; echo 'alert("Submission was not added. Please try again.")'; echo '</script>'; } } else { echo '<script language="JavaScript">'; echo 'alert("Unacceptable image extension.")'; echo '</script>'; } // 3 - B. VALIDATE IMAGE EXTENSION } // 2 - B. END SANITIZE AND VALIDATE EMAIL // 1 - B. END REQUIRED FIELDS VERIFICATION } else { print ' <ul class="errorlist"> <li class="alert">Please fill out the required fields.</li> '; if (empty($name)) { echo ' <li>* Full Name</li>' . "\n"; $errorname = 'TRUE'; } if (empty($email)) { echo ' <li>* Email</li>' . "\n"; $erroremail = 'TRUE'; } if (empty($email2)) { echo ' <li>* Confirm Email</li>' . "\n"; $erroremail2 = 'TRUE'; } if (empty($city)) { echo ' <li>* City</li>' . "\n"; $errorcity = 'TRUE'; } if (empty($state)) { echo ' <li>* State</li>' . "\n"; $errorstate = 'TRUE'; } if ($email != $email2) { echo ' <li>* Emails do not match.</li>' . "\n"; } if (empty($_FILES['featureupload']['tmp_name'])) { echo ' <li>* You did not upload a feature.</li>' . "\n"; $errorfile = 'TRUE'; } if (empty($featurename)) { echo ' <li>* Feature Name</li>' . "\n"; $errorfeature = 'TRUE'; } if ($featuresize >= $limitsize) { echo ' <li>* File size is too large.</li>' . "\n"; } print ' </ul> '; } // 1 - B. END REQUIRED FIELDS ERROR CODES } Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 20, 2010 Share Posted August 20, 2010 Hi I would look in the directory the tmp_name file is stored and check it really is uploaded. Also check the error display level you have set just in case the error messages are being suppressed. All the best Keith Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 No images are being saved whatsoever. Is there a way I can check what files were being temporarily stored in the tmp_name folder? Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 20, 2010 Share Posted August 20, 2010 Hi Crudely, echo out the tmp_name and find the directory that it is uploaded to, then mod the script again to loop through that directory and echo out the contents. All the best Keith Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 @kickstar.. I echo'd out my $_FILES['filename']['tmp_name'] and it returned: /tmp/phpjYiGQ5 I'm assuming this means that the file is at least being temporarily uploaded and that the problem lies where my image is not being successfully moved/resaved to the location I want it to. Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 20, 2010 Share Posted August 20, 2010 Hi Sounds likely. If you echo out a directory listing of /tmp in your script hopefully you can double check it really exists (probably does). Also check that the permissions allow you to write to the destination directory. All the best Keith Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 2 quick questions.. when my script echoed /tmp/phpjYiGQ5 was this path relative to the current URL? Also, my folder that I want my images to save onto is at 755 which I also believed was enough permission to write to since 777 is dangerous for public. Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 I echo'd out the directory listing of /tmp/ and saw no image names or anything resembling the image files at all. I see a bunch of other files with the extension ".log"... I'm so lost! Sorry for so many questions I'm just really trying to dissect the problem and solve this! Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 20, 2010 Share Posted August 20, 2010 Hi Think the uploaded file name has an absolute location. The file name will be meaningless. Think the permission needs to be 777. This is a bit insecure so the solution is to put it outside the web root (you can then pass them back out using a script). This might help:- http://www.mysql-apache-php.com/fileupload-security.htm All the best Keith Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 OK so I did a bit more error testing with this PHP: if(!move_uploaded_file($src, $target)) { echo '0 <br />'; } if(!imagecopyresampled($imgm, $img, 0,0,0,0,$imgx,$imgy,$ox,$oy)) { echo '1 <br />'; } if(!imagejpeg($imgm, $path_image . $filefull, 80)) { echo '2 <br />'; } So I was receiving all 3 errors. After I changed the permissions of the desired path to 777 I only received the first error which notifies me that "move_uploaded_file" isn't working correctly. However, I did notice that my images were now properly being saved. Should I be concerned with the first error? Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 20, 2010 Share Posted August 20, 2010 Hi Bit strange as I think move_uploaded_file should only return false when it has failed and so shouldn't have done anything. Might be worth checking it is really false rather than blank (ie if(move_uploaded_file($src, $target) === false) ) All the best Keith Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 Alright, one more problem: So with the permissions of the directory changed to 777, MOST uploaded images which fall under 1 mb I've noticed are successfully being uploaded, resized and saved in the right directory. However, I've noticed that when I attempt to upload some images at higher sizes (1.8mb, 2.2mb, 3.2mb) when I hit submit, it seems as though the script completely fails. There is no alert, I return to a page with the form missing, nothing was queried, images weren't saved, etc. I dove into the php.ini file to make sure max file size wasn't anything too low and i had a max file size of 32MB. Is there any other factors that are killing the script when I upload these images at those sizes? Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 20, 2010 Share Posted August 20, 2010 Hi Not sure. With a VERY large file possible the script is timing out. However on a *nix install I think it shouldn't care about the time waiting for a file to upload. All the best Keith Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 20, 2010 Share Posted August 20, 2010 For your latest symptom, would you say that it seems like if(!empty($_POST['submitFeature'])) is failing ($_POST['submitFeature'] IS empty)? If so, you are probably exceeding the post_max_size setting, in which case both the $_POST and $_FILES array will be empty. Your code should test for this condition as the first thing it checks. If both your form and your form processing code are on one page, you should actually use the following to test if the form was submitted, then test if the $_FILES array is not-empty, then put your other form processing logic - if($_SERVER['REQUEST_METHOD'] == 'POST'){ Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 Apologies for the thread repeat.. I was refreshing this thread hoping to see any replies and didn't see any until I noticed I was refreshing on the first page and the comments had already spanned to a second page. Anyways.. the current code is attached below. @kickstart.. On a very large file.. hmm. I'm ASSUMING you mean raw photos straight from a camera at 10mb+? I definitely have those options filtered out with my file size.. the images 3 images I tried were at 1.2mb, 2 mb and 3mb.. all which seemed to have broke or even timed out the script. I say this because I had no errors or alerts returned when I had submit. It just returned me back to the form page but without the form itself. Also, I'm not too familiar with "*nix".. @PFMaBiSmAd.. Wasn't aware that there was a post_max_size setting.. I'll look into this. if(!empty($_POST['submitFeature'])) { // set variables $featurename = mysql_real_escape_string($_POST['featurename']); $featuredesc = mysql_real_escape_string($_POST['featuredesc']); $name = mysql_real_escape_string($_POST['name']); $email = mysql_real_escape_string($_POST['email']); $email2 = mysql_real_escape_string($_POST['email2']); $age = mysql_real_escape_string($_POST['age']); $city = mysql_real_escape_string($_POST['city']); $state = mysql_real_escape_string($_POST['state']); $src = $_FILES['featureupload']['tmp_name']; $featuresize = $_FILES['featureupload']['size']; $limitsize = 1000000; // 1 - A. REQUIRED FIELDS VERIFICATION if(!empty($featurename) && !empty($name) && !empty($email) && !empty($email2) && !empty($city) && !empty($state) && ($email == $email2) && !empty($_FILES['featureupload']['tmp_name']) && ($featuresize < $limitsize)) { // 2 - A. SANITIZE AND VALIDATE EMAIL $email = filter_var($email, FILTER_SANITIZE_EMAIL); if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { print ' <ul class="errorlist"> <li class="alert">Error!</li> <li>Invalid Email Address</li> </ul> '; } else { // 3 - A. VALIDATE IMAGE EXTENSION // verify that image uploaded is proper extension $fname = strtolower($_FILES['featureupload']['name']); // grab uploaded image's filename and lowercase the extension (ex: .JPG) if(preg_match('/[.](jpg)|(gif)|(png)$/', $fname)) { // set image variables $path_image = 'submissions/'; $final_width_of_image = 550; $randomappend=rand(0000,9999); // generate random number to append to filename $src = $_FILES['featureupload']['tmp_name']; // grab the src for where the image is temporarily held $filefull = $randomappend . $fname; // initiate new file name for submission's full image $target = $path_image . $filefull; // set variable for submission image's new location with appended name $path_image_thumb = 'submissions/thumbs/'; $final_width_of_thumb = 166; $final_height_of_thumb = 120; $filethumb = $randomappend . $fname; // initiate new file name for submission's thumbnail $target_thumb = $path_image_thumb . $filethumb; // set variable for thumbnail's new location with appended name move_uploaded_file($src, $target); if(preg_match('/[.](jpg)$/', $filefull)){ $img = imagecreatefromjpeg($path_image . $filefull); } else if (preg_match('/[.](gif)$/', $filefull)){ $img = imagecreatefromgif($path_image . $filefull); } else if (preg_match('/[.](png)$/', $filefull)){ $img = imagecreatefrompng($path_image . $filefull); } // FULL SIZE IMAGE $ox = imagesx($img); $oy = imagesy($img); $imgx = $final_width_of_image; $imgy = floor($oy * ($final_width_of_image / $ox)); $imgm = imagecreatetruecolor($imgx, $imgy); imagecopyresampled($imgm, $img, 0,0,0,0,$imgx,$imgy,$ox,$oy); if(!file_exists($path_image)){ if(!mkdir($path_image)){ die("There was a problem."); } } imagejpeg($imgm, $path_image . $filefull, 80); // END FULL SIZE IMAGE // THUMBNAIL $tox = imagesx($img); $toy = imagesy($img); $tx = $final_width_of_thumb; $ty = $final_height_of_thumb; $tm = imagecreatetruecolor($tx, $ty); imagecopyresampled($tm, $img, 0,0,0,0,$tx,$ty,$tox,$toy); if(!file_exists($path_image_thumb)){ if(!mkdir($path_image_thumb)){ die("There was a problem."); } } imagejpeg($tm, $path_image_thumb . $filethumb, 80); // END THUMBNAIL // query the actual post forms $q = "INSERT INTO submissions (id, name, age, email, city, state, country, featurename, featuredesc, featureimg, featurethumb, postdate, approved) VALUES ('', '$name', '$age', '$email', '$city', '$state', '', '$featurename', '$featuredesc', '$target', '$target_thumb', NOW(), 'NO')"; $r = mysql_query($q); if($r) { echo '<script language="JavaScript">'; echo 'alert("Successfully added a submission.")'; echo '</script>'; } else { echo '<script language="JavaScript">'; echo 'alert("Submission was not added. Please try again.")'; echo '</script>'; } } else { echo '<script language="JavaScript">'; echo 'alert("Unacceptable image extension.")'; echo '</script>'; } // 3 - B. VALIDATE IMAGE EXTENSION } // 2 - B. END SANITIZE AND VALIDATE EMAIL // 1 - B. END REQUIRED FIELDS VERIFICATION } else { print ' <ul class="errorlist"> <li class="alert">Please fill out the required fields.</li> '; if (empty($name)) { echo ' <li>* Full Name</li>' . "\n"; $errorname = 'TRUE'; } if (empty($email)) { echo ' <li>* Email</li>' . "\n"; $erroremail = 'TRUE'; } if (empty($email2)) { echo ' <li>* Confirm Email</li>' . "\n"; $erroremail2 = 'TRUE'; } if (empty($city)) { echo ' <li>* City</li>' . "\n"; $errorcity = 'TRUE'; } if (empty($state)) { echo ' <li>* State</li>' . "\n"; $errorstate = 'TRUE'; } if ($email != $email2) { echo ' <li>* Emails do not match.</li>' . "\n"; } if (empty($_FILES['featureupload']['tmp_name'])) { echo ' <li>* You did not upload a feature.</li>' . "\n"; $errorfile = 'TRUE'; } if (empty($featurename)) { echo ' <li>* Feature Name</li>' . "\n"; $errorfeature = 'TRUE'; } if ($featuresize >= $limitsize) { echo ' <li>* File size is too large.</li>' . "\n"; } print ' </ul> '; } // 1 - B. END REQUIRED FIELDS ERROR CODES } Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 This might help solving this problem.. When I submit the form trying to upload a "larger" size image, it returns back to the same page with the form but WITHOUT the form. I view the source and it looks like the page stops loading where the script is. Is this a sign of timing out? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 20, 2010 Share Posted August 20, 2010 Since you haven't shown your form and how it relates to the code you have been posting, it is impossible to answer. Are you debugging this problem on a system with error_reporting set to E_ALL and display_errors set to ON so that all the errors php detects will both be reported and displayed? Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 I'm debugging on the client's server. Is there any way to check if error_reporting and display_errors is on via PHP? <?php if(!empty($_POST['submitFeature'])) { // set variables $featurename = mysql_real_escape_string($_POST['featurename']); $featuredesc = mysql_real_escape_string($_POST['featuredesc']); $name = mysql_real_escape_string($_POST['name']); $email = mysql_real_escape_string($_POST['email']); $email2 = mysql_real_escape_string($_POST['email2']); $age = mysql_real_escape_string($_POST['age']); $city = mysql_real_escape_string($_POST['city']); $state = mysql_real_escape_string($_POST['state']); $src = $_FILES['featureupload']['tmp_name']; $featuresize = $_FILES['featureupload']['size']; $limitsize = 3000000; // 1 - A. REQUIRED FIELDS VERIFICATION if(!empty($featurename) && !empty($name) && !empty($email) && !empty($email2) && !empty($city) && !empty($state) && ($email == $email2) && !empty($_FILES['featureupload']['tmp_name']) && ($featuresize < $limitsize)) { // 2 - A. SANITIZE AND VALIDATE EMAIL $email = filter_var($email, FILTER_SANITIZE_EMAIL); if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { print ' <ul class="errorlist"> <li class="alert">Error!</li> <li>Invalid Email Address</li> </ul> '; } else { // 3 - A. VALIDATE IMAGE EXTENSION // verify that image uploaded is proper extension $fname = strtolower($_FILES['featureupload']['name']); // grab uploaded image's filename and lowercase the extension (ex: .JPG) if(preg_match('/[.](jpg)|(gif)|(png)$/', $fname)) { // set image variables $path_image = 'submissions/'; $final_width_of_image = 550; $randomappend=rand(0000,9999); // generate random number to append to filename $src = $_FILES['featureupload']['tmp_name']; // grab the src for where the image is temporarily held $filefull = $randomappend . $fname; // initiate new file name for submission's full image $target = $path_image . $filefull; // set variable for submission image's new location with appended name $path_image_thumb = 'submissions/thumbs/'; $final_width_of_thumb = 166; $final_height_of_thumb = 120; $filethumb = $randomappend . $fname; // initiate new file name for submission's thumbnail $target_thumb = $path_image_thumb . $filethumb; // set variable for thumbnail's new location with appended name move_uploaded_file($src, $target); if(preg_match('/[.](jpg)$/', $filefull)){ $img = imagecreatefromjpeg($path_image . $filefull); } else if (preg_match('/[.](gif)$/', $filefull)){ $img = imagecreatefromgif($path_image . $filefull); } else if (preg_match('/[.](png)$/', $filefull)){ $img = imagecreatefrompng($path_image . $filefull); } // FULL SIZE IMAGE $ox = imagesx($img); $oy = imagesy($img); $imgx = $final_width_of_image; $imgy = floor($oy * ($final_width_of_image / $ox)); $imgm = imagecreatetruecolor($imgx, $imgy); imagecopyresampled($imgm, $img, 0,0,0,0,$imgx,$imgy,$ox,$oy); if(!file_exists($path_image)){ if(!mkdir($path_image)){ die("There was a problem."); } } imagejpeg($imgm, $path_image . $filefull, 80); // END FULL SIZE IMAGE // THUMBNAIL $tox = imagesx($img); $toy = imagesy($img); $tx = $final_width_of_thumb; $ty = $final_height_of_thumb; $tm = imagecreatetruecolor($tx, $ty); imagecopyresampled($tm, $img, 0,0,0,0,$tx,$ty,$tox,$toy); if(!file_exists($path_image_thumb)){ if(!mkdir($path_image_thumb)){ die("There was a problem."); } } imagejpeg($tm, $path_image_thumb . $filethumb, 80); // END THUMBNAIL // query the actual post forms $q = "INSERT INTO submissions (id, name, age, email, city, state, country, featurename, featuredesc, featureimg, featurethumb, postdate, approved) VALUES ('', '$name', '$age', '$email', '$city', '$state', '', '$featurename', '$featuredesc', '$target', '$target_thumb', NOW(), 'NO')"; $r = mysql_query($q); if($r) { echo '<script language="JavaScript">'; echo 'alert("Successfully added a submission.")'; echo '</script>'; } else { echo '<script language="JavaScript">'; echo 'alert("Submission was not added. Please try again.")'; echo '</script>'; } } else { echo '<script language="JavaScript">'; echo 'alert("Unacceptable image extension.")'; echo '</script>'; } // 3 - B. VALIDATE IMAGE EXTENSION } // 2 - B. END SANITIZE AND VALIDATE EMAIL // 1 - B. END REQUIRED FIELDS VERIFICATION } else { print ' <ul class="errorlist"> <li class="alert">Please fill out the required fields.</li> '; if (empty($name)) { echo ' <li>* Full Name</li>' . "\n"; $errorname = 'TRUE'; } if (empty($email)) { echo ' <li>* Email</li>' . "\n"; $erroremail = 'TRUE'; } if (empty($email2)) { echo ' <li>* Confirm Email</li>' . "\n"; $erroremail2 = 'TRUE'; } if (empty($city)) { echo ' <li>* City</li>' . "\n"; $errorcity = 'TRUE'; } if (empty($state)) { echo ' <li>* State</li>' . "\n"; $errorstate = 'TRUE'; } if ($email != $email2) { echo ' <li>* Emails do not match.</li>' . "\n"; } if (empty($_FILES['featureupload']['tmp_name'])) { echo ' <li>* You did not upload a feature.</li>' . "\n"; $errorfile = 'TRUE'; } if (empty($featurename)) { echo ' <li>* Feature Name</li>' . "\n"; $errorfeature = 'TRUE'; } if ($featuresize >= $limitsize) { echo ' <li>* File size is too large.</li>' . "\n"; } print ' </ul> '; } // 1 - B. END REQUIRED FIELDS ERROR CODES } ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <div style="float: left;"> <h2>Your Infomation</h2><br /> <div class="formSec"><label for="name" class="required">Full Name: <?php if(isset($errorname)){echo '<span class="error">*<span>';}?></label> <input type="text" name="name" id="name" value="" /></div> <div class="formSec"><label for="email" class="required">Email: <?php if(isset($erroremail)){echo '<span class="error">*<span>';}?></label> <input type="text" name="email" id="email" value="" /></div> <div class="formSec"><label for="email2" class="required">Confirm Email: <?php if(isset($erroremail2)){echo '<span class="error">*<span>';}?></label> <input type="text" name="email2" id="email2" value="" /></div> <div class="formSec"><label for="age" class="required">Year of Birth:</label> <select name="age" id="age"> <option value="2010" label="2010">2010</option> <option value="2009" label="2009">2009</option> <option value="2008" label="2008">2008</option> <option value="2007" label="2007">2007</option> <option value="2006" label="2006">2006</option> <option value="2005" label="2005">2005</option> <option value="2004" label="2004">2004</option> <option value="2003" label="2003">2003</option> <option value="2002" label="2002">2002</option> <option value="2001" label="2001">2001</option> <option value="2000" label="2000">2000</option> <option value="1999" label="1999">1999</option> <option value="1998" label="1998">1998</option> <option value="1997" label="1997">1997</option> <option value="1996" label="1996">1996</option> <option value="1995" label="1995">1995</option> <option value="1994" label="1994">1994</option> <option value="1993" label="1993">1993</option> <option value="1992" label="1992">1992</option> <option value="1991" label="1991">1991</option> <option value="1990" label="1990">1990</option> <option value="1989" label="1989">1989</option> <option value="1988" label="1988">1988</option> <option value="1987" label="1987">1987</option> <option value="1986" label="1986">1986</option> <option value="1985" label="1985">1985</option> <option value="1984" label="1984">1984</option> <option value="1983" label="1983">1983</option> <option value="1982" label="1982">1982</option> <option value="1981" label="1981">1981</option> <option value="1980" label="1980">1980</option> <option value="1979" label="1979">1979</option> <option value="1978" label="1978">1978</option> <option value="1977" label="1977">1977</option> <option value="1976" label="1976">1976</option> <option value="1975" label="1975">1975</option> <option value="1974" label="1974">1974</option> <option value="1973" label="1973">1973</option> <option value="1972" label="1972">1972</option> <option value="1971" label="1971">1971</option> <option value="1970" label="1970">1970</option> <option value="1969" label="1969">1969</option> <option value="1968" label="1968">1968</option> <option value="1967" label="1967">1967</option> <option value="1966" label="1966">1966</option> <option value="1965" label="1965">1965</option> <option value="1964" label="1964">1964</option> <option value="1963" label="1963">1963</option> <option value="1962" label="1962">1962</option> <option value="1961" label="1961">1961</option> <option value="1960" label="1960">1960</option> <option value="1959" label="1959">1959</option> <option value="1958" label="1958">1958</option> <option value="1957" label="1957">1957</option> <option value="1956" label="1956">1956</option> <option value="1955" label="1955">1955</option> <option value="1954" label="1954">1954</option> <option value="1953" label="1953">1953</option> <option value="1952" label="1952">1952</option> <option value="1951" label="1951">1951</option> <option value="1950" label="1950">1950</option> </select></div> <div class="formSec"><label for="city" class="required">City: <?php if(isset($errorcity)){echo '<span class="error">*<span>';}?></label> <input type="text" name="city" id="city" value="" /></div> <div class="formSec"><label for="state" class="required">State: <?php if(isset($errorstate)){echo '<span class="error">*<span>';}?></label> <select name="state" id="state"> <option value="">STATE</option> <option value="AL" <?PHP if($state=="AL") echo "selected";?>>Alabama</option> <option value="AK" <?PHP if($state=="AK") echo "selected";?>>Alaska</option> <option value="AZ" <?PHP if($state=="AZ") echo "selected";?>>Arizona</option> <option value="AR" <?PHP if($state=="AR") echo "selected";?>>Arkansas</option> <option value="CA" <?PHP if($state=="CA") echo "selected";?>>California</option> <option value="CO" <?PHP if($state=="CO") echo "selected";?>>Colorado</option> <option value="CT" <?PHP if($state=="CT") echo "selected";?>>Connecticut</option> <option value="DE" <?PHP if($state=="DE") echo "selected";?>>Delaware</option> <option value="FL" <?PHP if($state=="FL") echo "selected";?>>Florida</option> <option value="GA" <?PHP if($state=="GA") echo "selected";?>>Georgia</option> <option value="HI" <?PHP if($state=="HI") echo "selected";?>>Hawaii</option> <option value="ID" <?PHP if($state=="ID") echo "selected";?>>Idaho</option> <option value="IL" <?PHP if($state=="IL") echo "selected";?>>Illinois</option> <option value="IN" <?PHP if($state=="IN") echo "selected";?>>Indiana</option> <option value="IA" <?PHP if($state=="IA") echo "selected";?>>Iowa</option> <option value="KS" <?PHP if($state=="KS") echo "selected";?>>Kansas</option> <option value="KY" <?PHP if($state=="KY") echo "selected";?>>Kentucky</option> <option value="LA" <?PHP if($state=="LA") echo "selected";?>>Louisiana</option> <option value="ME" <?PHP if($state=="ME") echo "selected";?>>Maine</option> <option value="MD" <?PHP if($state=="MD") echo "selected";?>>Maryland</option> <option value="MA" <?PHP if($state=="MA") echo "selected";?>>Massachusetts</option> <option value="MI" <?PHP if($state=="MI") echo "selected";?>>Michigan</option> <option value="MN" <?PHP if($state=="MN") echo "selected";?>>Minnesota</option> <option value="MS" <?PHP if($state=="MS") echo "selected";?>>Mississippi</option> <option value="MO" <?PHP if($state=="MO") echo "selected";?>>Missouri</option> <option value="MT" <?PHP if($state=="MT") echo "selected";?>>Montana</option> <option value="NE" <?PHP if($state=="NE") echo "selected";?>>Nebraska</option> <option value="NV" <?PHP if($state=="NV") echo "selected";?>>Nevada</option> <option value="NH" <?PHP if($state=="NH") echo "selected";?>>New Hampshire</option> <option value="NJ" <?PHP if($state=="NJ") echo "selected";?>>New Jersey</option> <option value="NM" <?PHP if($state=="NM") echo "selected";?>>New Mexico</option> <option value="NY" <?PHP if($state=="NY") echo "selected";?>>New York</option> <option value="NC" <?PHP if($state=="NC") echo "selected";?>>North Carolina</option> <option value="ND" <?PHP if($state=="ND") echo "selected";?>>North Dakota</option> <option value="OH" <?PHP if($state=="OH") echo "selected";?>>Ohio</option> <option value="OK" <?PHP if($state=="OK") echo "selected";?>>Oklahoma</option> <option value="OR" <?PHP if($state=="OR") echo "selected";?>>Oregon</option> <option value="PA" <?PHP if($state=="PA") echo "selected";?>>Pennsylvania</option> <option value="RI" <?PHP if($state=="RI") echo "selected";?>>Rhode Island</option> <option value="SC" <?PHP if($state=="SC") echo "selected";?>>South Carolina</option> <option value="SD" <?PHP if($state=="SD") echo "selected";?>>South Dakota</option> <option value="TN" <?PHP if($state=="TN") echo "selected";?>>Tennessee</option> <option value="TX" <?PHP if($state=="TX") echo "selected";?>>Texas</option> <option value="UT" <?PHP if($state=="UT") echo "selected";?>>Utah</option> <option value="VT" <?PHP if($state=="VT") echo "selected";?>>Vermont</option> <option value="VA" <?PHP if($state=="VA") echo "selected";?>>Virginia</option> <option value="WA" <?PHP if($state=="WA") echo "selected";?>>Washington</option> <option value="WV" <?PHP if($state=="WV") echo "selected";?>>West Virginia</option> <option value="WI" <?PHP if($state=="WI") echo "selected";?>>Wisconsin</option> <option value="WY" <?PHP if($state=="WY") echo "selected";?>>Wyoming</option> </select> </div> </div> <div style="float: left; margin-left: 30px;"> <h2>Your Feature</h2><br /> <div class="formSec"><label for="featurename" class="required">Feature Name: <?php if(isset($errorfeature)){echo '<span class="error">*<span>';}?></label> <input type="text" name="featurename" id="featurename" value="" /></div> <div class="formSec"><label for="featuredesc" class="required">Feature Description:</label> <textarea name="featuredesc" id="featuredesc" cols="20"></textarea></div> <div class="formSec"><label for="featureupload" class="required">Upload Feature: (max: 1MB) <?php if(isset($errorfile)){echo '<span class="error">*<span>';}?></label> <input type="hidden" class="hidden" name="max_file_size" value="9999999999999" /> <input type="file" name="featureupload" id="featureupload" size="18" /></div> </div> <div class="break"></div> <input class="submit" type="submit" name="submitFeature" value="Submit Your Feature" /> </form> Quote Link to comment Share on other sites More sharing options...
codeline Posted August 20, 2010 Author Share Posted August 20, 2010 Alright, current update: Added ini_set('display_errors',1); and error_reporting(E_ALL|E_STRICT); to my PHP and noticed that there were some undefined variables in my form (the State input area). I went ahead and deleted all those if statements within each State input and now images at higher sizes (but also under file limit size) are being uploaded successfully. Could undefined variables really have caused the script to time out/ crash? 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.