Jump to content

Problems displaying a picture on a form processing page


jackie11

Recommended Posts

Hi

I am having difficulty displaying a picture which has been uploaded in a form

The 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
Hi

I 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?

Thanks

Jackie
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
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.