Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

I need a simple form with an upload button!

  • 25-08-2012 08:38PM
    #1
    Registered Users, Registered Users 2 Posts: 9,845 ✭✭✭


    Hi all,

    I desperately need a simple form that will give the user an option to upload a file. I know this will probably involve some php and thats fine.

    Basically, all I need is a text box for their Name, one for an email address, text area for a comment, an upload button so they can select a file and send.

    It can either go to a folder on the server or to an email address, whichever is easier.

    Can anybody help??


Comments

  • Registered Users, Registered Users 2 Posts: 9,845 ✭✭✭py2006


    I have the basic html form. When the file is submitted the user can be brought to a page thanking them for the comment and upload?

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    </head>

    <body>


    <form action="" method="get" name="upload form">


    Name: <input name="name" type="text" value="name">
    <br>
    Comment:<textarea name="comment" cols="" rows=""></textarea><br>

    Upload your file<input name="upload" type="file" size="10"></select><br>
    <br>

    <input name="Submit" value="Submit" type="button">

    </form>
    </body>
    </html>


  • Registered Users, Registered Users 2 Posts: 1,757 ✭✭✭Deliverance XXV


    Excellent info here: http://www.w3schools.com/php/php_file_upload.asp.
    Well worth trying out the code yourself as you will learn it much quicker.

    Don't forget to add the enctype to your form's HTML as it will not process the file otherwise.
    [PHP]
    <form action="upload_file.php" method="post" enctype="multipart/form-data">
    <!-- Code -->
    </form>[/PHP]


  • Registered Users, Registered Users 2 Posts: 1,757 ✭✭✭Deliverance XXV


    py2006 wrote: »
    I have the basic html form. When the file is submitted the user can be brought to a page thanking them for the comment and upload?

    At the end of your PHP upload script you can add something like this and it will redirect the user once the script has been processed.

    [PHP]<?php

    //Your code
    header('Location: thank-you.php');

    ?>[/PHP]


Advertisement