View Single Post
Old 06-28-2009, 08:09 AM   #4 (permalink)
Costin Trifan
Meeow!
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 3,235
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest order
Technically speaking, you cannot do that. Mainly because to be able to upload a file to a server you need a file upload control(the file input tag), then you have to use the $_FILES array on your code and copy the file to a specified location.

But then you say that
Quote:
The contact form was a simple php script to send the contents of a text field to my e-mail address.
which confuses me...because a simple contact form would normally not have a file upload control or even touch the $_FILES array in the code behind file.

Maybe you are looking into the wrong direction and the contact form is not the one with problems here, maybe the other form you were talking about?

To avoid some headaches, you can just have your contact form validation file look like this:
PHP Code:
<?php
    
if ($_SERVER['REQUEST_METHOD'] == 'POST')
    {
                
// Sanitize posted data
        
$subject trim(stripslashes(strip_tags($_POST['subject'])));
        
//
        //... continue with the rest of your form's controls
        
        //.. validate the posted data
        
if (empty($subject))
            exit(
'You need to provide a subject');
        if (
strlen($subject) > 125)
            exit(
'The subject is too long');
        
//
        //... etc...
    
}
    else exit(
'Invalid request method');
?>
__________________
...to be continued
Costin Trifan is offline   Reply With Quote