Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Upload forms HELP!!!

Sep 21, 2007 2:14AM PDT

Hi everyone!

I need to have a web page that allows visitors to email me their favorite photo and I am using basic html and PHP. However, I am doing something wrong, because I receive the visitor's information but not the image.

PLEASE HELP!

Here is the page's html:

<form method="post" action="photos.php" enctype="multipart/form-data">


<table cellspacing=0 cellpadding=5 width="95%" border=1 bordercolor="#3399FF">
<tbody>
<tr>


<td width="40%" class="blackp"><strong>Name of mum-to-be:</strong> </td>
<td width="60%"><div align="left" class="blackp">
<input type="text" maxlength=35 size=45 name="name" />
</div></td>
</tr>
<tr>

<td class="blackp" width="40%"><strong>Email address:</strong> </td>
<td width="60%"><div align="left" class="blackp">
<input type="text" maxlength=35 size=45 name="email" />
</div></td>
</tr>
<tr>

<td class="blackp" width="40%"><strong>Phone number:</strong> </td>
<td width="60%"><div align="left" class="blackp">
<input type="text" maxlength=15 size=45 name="phone" />
</div></td>
</tr>
<tr>

<td class="blackp" width="40%"><input type="hidden" name="max_file_size" value="1000000" />
<strong>Photo to be uploaded:</strong> </td>
<td width="60%"><div align="left" class="blackp">
<input type="file" name="uploadfile" size="45" />

</div></td>
</tr>
<tr>

<td class="blackp" width="40%"><strong>Photo captions:</strong> </td>
<td width="60%"><div align="left" class="blackp">
<input type="text" maxlength=70 size=45 name="captions" />
</div></td>
</tr>
<tr>
<td width="40%" height=19 class="blackp">Click button to <strong>send
your email</strong>.</td>
<td width="60%" class="blackp"><input name="contactus" type = "submit" class="blackp" value="send" /></td>
</tr>
</tbody>
</table>

</form>

And here is the PHP coding:

<?


$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$uploadfile = $_REQUEST['uploadfile'] ;
$explanation = $_REQUEST['explanation'] ;
$captions = $_REQUEST['captions'] ;

if (!isset($_REQUEST['email'])) {
header( "Location: http://www.britishbabyshower.co.uk/photos.html" );
}


elseif (empty($name) || empty($email)) {
header( "Location: http://www.britishbabyshower.co.uk/error.html" );
}


else {
mail( "babiesonthego@yahoo.com", "Contact Us Form",
"Name: $name\nPhone Number: $phone\nEmail Address: $email\nImage Uploaded: $uploadfile\nCaptions: $captions",
"From: $name <$email>" );

header( "Location: http://www.britishbabyshower.co.uk/thankyou.html" );
}

?>

Discussion is locked

- Collapse -
Question
Sep 21, 2007 8:49AM PDT

1. where did u get the script from?
2. where does it upload the photo to?
- do u have chmod set correctly?

~Sovereign

- Collapse -
File Upload
Sep 22, 2007 11:46AM PDT

Yes you must be sure to change the permissions on the upload directory.
However this poses a security risk, you must as a result have authentication ... properly implemented, session based or whatever. Also please pay close attention to the file types you allow to be uploaded.

Shelon Padmore
http://shelonpadmore.blogspot.com/