Modernvox Posted March 9, 2010 Share Posted March 9, 2010 What's up brothers.. For the past week I have been Working on implementing an Image Preview During the Submission Process. All is Working Well up until lines 104-115. Seems one or the other is allowed "That is, either the image will show alone, or text will show alone (If i attempt to display both at once only the text shows and the image shows as a 403 Forbidden access error. In addition, I would also like to know if any of you have experience with image resizing as I only want to display a set thumbnail size. Here is the code in question. As always "your time is greatly appreciated". <?php error_reporting(E_ALL); ini_set("display_errors", 1); if ($_POST['submit']){ if (!$_POST['location'] || !$_POST['actual_location'] || !$_POST['name'] || !$_POST['influences'] || !$_POST['exp'] || !$_POST['bio']) { die('Missing required fields detected'); } $location= $_POST['location']; $actual_location= $_POST['actual_location']; $name= $_POST['name']; $influences= $_POST['influences']; $exp= $_POST['exp']; $bio= $_POST['bio']; $errorlist= array(); $maxsize=28480; if ($location== "") { $errorlist[]= "ERROR: <font color= \"red\">You must choose a location</font>"; } if ($actual_location== "") { $errorlist[]= "ERROR: <font color= \"red\">You must enter your actual location for user search</font>"; } if ($name== "" || strlen($name) >50) { $errorlist[]= "ERROR: <font color= \"red\">Name must between 1-50 characters in length</font>"; } if ($influences == "" || strlen($influences) >30) { $errorlist[] = "ERROR: <font color= \"red\">1-30 characters allowed for influences</font>"; } if ($exp== "" || strlen($exp) >100) { $errorlist[]= "ERROR: <font color= \"red\">1-100 characters allowed for experience</font>"; } if ($bio == "" || strlen($bio) >250) { $errorlist[]= "ERROR: <font color= \"red\">1- 250 characters allowed for bio"; echo" you currently have strlen($bio)</font>"; } if (sizeof($errorlist) > 0) { echo "Please review and correct the following erro rs by clicking your browsers back button <br/>"; foreach ($errorlist as $e) { echo "$e <br/>"; }exit(); } $maxsize=28480; $photo= $_FILES['photo']; if (!is_uploaded_file($_FILES['photo']['tmp_name'])) { $errorlist = "ERROR: <font color= \"red\">You must upload a file!</font>"; } if ($_FILES['photo']['type'] != "image/gif" AND $_FILES['photo']['type'] != "image/pjpeg" AND $_FILES['photo']['type'] !="image/jpeg") { $errorlist = "ERROR: <font color= \"red\">You may only upload .gif or .jpeg files</font>"; } if ($_FILES['photo']['size']> $maxsize) { $errorlist = "ERROR: <font color= \"red\">file must be less than $maxsize bytes.</font>"; unlink($_FILES['photo']['tmp_name']); } else { move_uploaded_file($_FILES['photo']['tmp_name'], "./uploads/".$_FILES['photo']['name']); [b]//line104[/b] print "<img src=\"./uploads/{$_FILES['photo']['name']}"; echo "<b><font color= \"black\">Experience:</font></b>" . $exp. "</br>"; echo $influences . "<br/>"; echo $actual_location . "<br/><br/>"; echo $bio . "<br/>"; [b]//line110 [/b] } } Quote Link to comment https://forums.phpfreaks.com/topic/194574-working-on-image-preview-during-submission-process-all-working-well-exce/ Share on other sites More sharing options...
Andy-H Posted March 9, 2010 Share Posted March 9, 2010 On line 105 (print statement), you didn't close your img tag... Quote Link to comment https://forums.phpfreaks.com/topic/194574-working-on-image-preview-during-submission-process-all-working-well-exce/#findComment-1023305 Share on other sites More sharing options...
Modernvox Posted March 9, 2010 Author Share Posted March 9, 2010 On line 105 (print statement), you didn't close your img tag... Thanks for pointing that out Andy, but it had no effect. If i comment out the 4 echo statements the image shows. It's either the text or image, never both. Quote Link to comment https://forums.phpfreaks.com/topic/194574-working-on-image-preview-during-submission-process-all-working-well-exce/#findComment-1023311 Share on other sites More sharing options...
Modernvox Posted March 10, 2010 Author Share Posted March 10, 2010 still no go..... Quote Link to comment https://forums.phpfreaks.com/topic/194574-working-on-image-preview-during-submission-process-all-working-well-exce/#findComment-1024325 Share on other sites More sharing options...
Psycho Posted March 10, 2010 Share Posted March 10, 2010 On line 105 (print statement), you didn't close your img tag... Thanks for pointing that out Andy, but it had no effect. If i comment out the 4 echo statements the image shows. It's either the text or image, never both. Are you sure about that? This is what is in the script above print "<img src=\"./uploads/{$_FILES['photo']['name']}"; Which will produce something like this <img src="./uploads/filename.jpg Since you don't close the src parameter (or the img tag), the browser gets confused. I'm guessing it works when you don't include the other echos because the browser is not seeing any other content after that so it "assumes" that is the end of the source and "fixes" the mistake. Change that line to this: print "<img src=\"./uploads/{$_FILES['photo']['name']}\" />"; Are you using IE for testing? If so, try switching to FF. IE has a habit of trying to "correct" malformed HTML. So, if you have errors in the HTML code it may look fine in IE, but not in other browsers. Also, when you have these types of error, it helps to look at the actual HTML produced. Trying to spot HTML errors in PHP code can be difficult. Quote Link to comment https://forums.phpfreaks.com/topic/194574-working-on-image-preview-during-submission-process-all-working-well-exce/#findComment-1024333 Share on other sites More sharing options...
Modernvox Posted March 10, 2010 Author Share Posted March 10, 2010 On line 105 (print statement), you didn't close your img tag... Thanks for pointing that out Andy, but it had no effect. If i comment out the 4 echo statements the image shows. It's either the text or image, never both. Are you sure about that? This is what is in the script above print "<img src=\"./uploads/{$_FILES['photo']['name']}"; Which will produce something like this <img src="./uploads/filename.jpg Since you don't close the src parameter (or the img tag), the browser gets confused. I'm guessing it works when you don't include the other echos because the browser is not seeing any other content after that so it "assumes" that is the end of the source and "fixes" the mistake. Change that line to this: print "<img src=\"./uploads/{$_FILES['photo']['name']}\" />"; Are you using IE for testing? If so, try switching to FF. IE has a habit of trying to "correct" malformed HTML. So, if you have errors in the HTML code it may look fine in IE, but not in other browsers. Also, when you have these types of error, it helps to look at the actual HTML produced. Trying to spot HTML errors in PHP code can be difficult. Ahhhh..You the man. Not only did I leave out the ending slash /> I also left out the double quotes \" Thanks a bunch....Do you recommend any tutorials on how to resize these images to a thumbnail? Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/194574-working-on-image-preview-during-submission-process-all-working-well-exce/#findComment-1024341 Share on other sites More sharing options...
Andy-H Posted March 10, 2010 Share Posted March 10, 2010 http://uk.php.net/manual/en/function.imagick-resizeimage.php Not documented but check out the user comments. The last one on the page shows what you need... Quote Link to comment https://forums.phpfreaks.com/topic/194574-working-on-image-preview-during-submission-process-all-working-well-exce/#findComment-1024474 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.