jackie11 Posted January 21, 2007 Share Posted January 21, 2007 Hi I am having difficulty displaying a picture which has been uploaded in a formThe code I use is:[code]<form method="GET" action="form_display.php" enctype="multipart/form-data"> [/code][code]<?php $Employee_ID = $_GET['Employee_ID'];$Surname = $_GET['Surname'];$Forename = $_GET['Forename'];$Job_title = $_GET['Job_title'];$Office_location = $_GET['Office_location'];$Telephone = $_GET['Telephone'];$Email = $_GET['Email'];$Expertise = $_GET['Expertise'];$Hobbies = $_GET['Hobbies'];$DOB = $_GET['DOB'];$Picture = $_GET['Picture'];?><table align="center" cellspacing="15"> <tbody> <tr> <td style="text-align: center;"><a href="$Picture" picture=" " border="0"><img src=<?php echo $Picture ?> picture="" border="0" height="100" width="90"></a></td> <td style="text-align: center;"></td> </tr> </tbody></table>[/code]I know it is all over the place but I have been making changes to try and get it to display the picture any suggestions on how to set this up?Jackie Quote Link to comment Share on other sites More sharing options...
trq Posted January 21, 2007 Share Posted January 21, 2007 If the picture has been uploaded it will be in the $_FILES array, not $_GET. You might want to take a look at a tutorial or two regarding how to handle PHP file uploads. Quote Link to comment Share on other sites More sharing options...
jackie11 Posted January 21, 2007 Author Share Posted January 21, 2007 HiI have already had a look at several tutorials but I just seem to be confusing my self more and more as nothing seems to work, I continurewd to play around with the code and have come up with:[code]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <title>form_display.php</title> <link rel="stylesheet" href="etc/TJConsultants.css"></head><body><br><div id="wrapper"><div id="header"><div style="text-align: center;"><br></div><br></div><div id="centercolumn"><div style="text-align: center;"><br></div><div style="text-align: center;"><hr style="width: 100%; height: 2px;"><font style="color: rgb(21, 27, 84);" size="+3">Employee Details<br></font><hr style="width: 100%; height: 2px;"><font style="color: rgb(21, 27, 84);" size="+3"></font><?php $Employee_ID = $_GET['Employee_ID'];$Surname = $_GET['Surname'];$Forename = $_GET['Forename'];$Job_title = $_GET['Job_title'];$Office_location = $_GET['Office_location'];$Telephone = $_GET['Telephone'];$Email = $_GET['Email'];$Expertise = $_GET['Expertise'];$Hobbies = $_GET['Hobbies'];$DOB = $_GET['DOB'];move_uploaded_file ($_FILES['Picture'] ['tmp_name'], "../uploads/{$_FILES['Picture'] ['name']}") ?><table align="center" cellspacing="15"> <tbody> <tr> <td style="text-align: center;"><a href="$Picture" picture=" " border="0"><img src=<?php echo $Picture ?> picture="" border="0" height="100" width="90"></a></td> <td style="text-align: center;"></td> </tr> </tbody></table><BR> <table style="text-align: left; margin-left: auto; margin-right: auto; width: 490px; height: 495px;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="text-align: left; vertical-align: middle; font-family: Tahoma; color: rgb(0, 0, 102);">Employee ID:</td> <td colspan="10":><?php echo $Employee_ID ?></td> </td> </tr> <tr> <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Surname:</td> <td colspan="10":><?php echo $Surname ?></td> </tr> <tr> <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Forename:</td> <td colspan="10":><?php echo $Forename ?></td> </tr> <tr> <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Job Title:</td> <td colspan="10":><?php echo $Forename ?></td> </tr> <tr> <td style="font-family: Tahoma; color: rgb(0, 0, 102);">DOB:</td> <td colspan="10":><?php echo $DOB ?></td> </tr> <tr> <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Telephone:</td> <td colspan="10":><?php echo $Telephone ?></td> </tr> <tr> <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Email:</td> <td colspan="10":><?php echo $Email ?></td> </tr> <tr> <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Office Location:</td> <td colspan="10":><?php echo $Office_location ?></td> </tr> </tbody></table><hr style="width: 100%; height: 2px;"><table><tbody> <tr> <td style="text-align: colspan ='20'; left; font-family: Tahoma; color: rgb(0, 0, 102);">Expertise:</td> <td colspan="10":><?php echo $Expertise ?></td> </tr> </tbody></table><BR><hr style="width: 100%; height: 2px;"><table><tbody> <tr> <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Hobbies:</td> <td colspan="10":><?php echo $Hobbies ?></td> </tr> </tbody></table><hr style="width: 100%; height: 2px;"><br><div style="text-align: left;"><a href="index.html"><img style="border: 0px solid ; width: 94px; height: 46px;" alt="Home" src="etc/Home_button.JPG"></a><br></div></div></div><div id="footer"><p style="text-align: left;"></p></div></div></body></html>[/code]But I'm still not sure if this is right and how I to get the picture to display, could anyone help or point me in the right direction?ThanksJackie Quote Link to comment Share on other sites More sharing options...
jackie11 Posted January 21, 2007 Author Share Posted January 21, 2007 Hi can anyone help with this, I have been working away on it but can't seem to get anything to work properly!Jackie Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 Well the variable $Picture is never defined. Quote Link to comment Share on other sites More sharing options...
jackie11 Posted January 21, 2007 Author Share Posted January 21, 2007 Hi Yes sorry my code is all over the place because I have been trying a number of things out, I know I need to define $Picture but am not sure how to do this after I have used the $_FILE, and copied the file from the temporary folder, is it something like:[code]<?php $Employee_ID = $_GET['Employee_ID'];$Surname = $_GET['Surname'];$Forename = $_GET['Forename'];$Job_title = $_GET['Job_title'];$Office_location = $_GET['Office_location'];$Telephone = $_GET['Telephone'];$Email = $_GET['Email'];$Expertise = $_GET['Expertise'];$Hobbies = $_GET['Hobbies'];$DOB = $_GET['DOB'];move_uploaded_file ($_FILES['Picture'] ['tmp_name'], "../uploads/{$_FILES['Picture'] ['name']}") $picture= $_FILES ['Picture']; ?>[/code]Jackie Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 You just use the url to the file. You put it in the uploads folder, so that's the start of the path. Then $_FILES['Picture'] ['name'] Quote Link to comment Share on other sites More sharing options...
jackie11 Posted January 22, 2007 Author Share Posted January 22, 2007 I still can't get this to work, I think its a problem with upload as after using the following code I get the message that "There was an error uploading your picture file, please try again!"Any suggestions?[code]<?php $Employee_ID = $_GET['Employee_ID'];$Surname = $_GET['Surname'];$Forename = $_GET['Forename'];$Job_title = $_GET['Job_title'];$Office_location = $_GET['Office_location'];$Telephone = $_GET['Telephone'];$Email = $_GET['Email'];$Expertise = $_GET['Expertise'];$Hobbies = $_GET['Hobbies'];$DOB = $_GET['DOB'];$target_path = "../page_g/pics/";$target_path = $target_path . basename( $_FILES['Picture']['name']); if(move_uploaded_file($_FILES['Picture']['tmp_name'], $target_path)) {echo "The file ". basename( $_FILES['Picture']['name']). " has been uploaded";} else{ echo "There was an error uploading your picture file, please try again!";} $Picture = basename($_FILES['Picture']['name']); ?>[/code] Quote Link to comment Share on other sites More sharing options...
scott212 Posted January 22, 2007 Share Posted January 22, 2007 I thought you were forced to use a POST method with enctype="multipart/form-data" in the form declaration? 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.