Setting up an image placeholder
Posted: Wed Jul 28, 2010 6:59 am
I have some code that allows a user to upload a small image file. It all works well, but I would like to have an image placeholder in a page for the occasions when the user chooses not to upload an image. Can anyone help? I an a bit confounded at the moment. My code follows.
Then I upload the image file like this...
Thanks.
Code: Select all
//Use the users numerical id to name the image file
$newname = $id .".jpg";
// Set the folder to upload to.
// Upload the file
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], "memberFiles/".$newname)) {
echo "Your image has been uploaded and will be displayed on several pages.<br /><br />
<a href=\"member_account.php\">Click here</a> to return to your profile edit area";
exit();Code: Select all
<table>
<form action="upload_image.php" method="post" enctype="multipart/form-data" name="form" id="form" >
<tr>
<td width="20"></td>
<td width="810" align="center"><div style="border:1px solid green;" align=center><img src="memberFiles/<?php echo "$id"; ?>.jpg" alt="Your School Logo"/></div><br /></td>
<td></td>
</tr>
<tr>
<td></td>
<td><div align="center">
<input name="uploadedfile" type="file" />
</div></td>
<td></td>
</tr>
<tr>
<td width="400"></td>
<td width="250"><div align="center"><input type="submit" name="Submit" value="Upload Image" /></div></td>
<td width="400"><div align="left">Return to your <br /><a href="member_account.php">Profile Page</a></div></td>
</tr>
</form>
</table>