trouble with a form, no error message

jlknauff

New member
Aug 25, 2008
237
1
0
I am building a form that will collect data and upload images.

Right now I'm just trying to get the uploading part worked out. When the form calls the php file to process everything, it works fine, but when I try to pull the form and the php into a single page, it fails to process and doesn't give any error message. The page just refreshes and presents the form again.

Can anyone see anything wrong with my approach here:

PHP:
<?php

if(isset($_POST['uploadedfile'])){

    // Where the file is going to be placed 
    $target_path = "uploads/";
    
    /* Add the original filename to our target path.  
    Result is "uploads/filename.extension" */
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    
    $target_path = "uploads/";
    
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    
}

if (empty($_POST['uploadedfile'])){

    echo '<form enctype="multipart/form-data" action="">';
    echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000" />';
    echo 'Choose a file to upload: <input name="uploadedfile" type="file" /><br />';
    echo '<input type="submit" value="Upload File" />';
    echo '</form>';
}

?>

If it helps, it's a modification of this: PHP Tutorial - File Upload
 


Oh for Christ's sake...I hate when I miss something stupid...

PHP:
method="post"

Solved.