trouble with a form, no error message

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

trouble with a form, no error message

Post by someguyhere »

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:

Code: Select all

<?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: http://www.tizag.com/phpT/fileupload.php
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

Re: trouble with a form, no error message

Post by someguyhere »

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

Code: Select all

method="post" 
Solved.
Post Reply