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.

File upload to website advice?

  • 20-09-2007 04:16AM
    #1
    Registered Users, Registered Users 2, Paid Member Posts: 34,487 ✭✭✭✭


    Hey folks, Im looking for a way to be able to upload a file (video file) onto a website. Just something where a user can click a browse button, pick a file and have it upload onto the page/server folder. Basically what youtube etc do, but as easy and straight forward as possible.
    Hope someone can help,
    Thanks!

    Subscribe to save Boards.ie from closing down: The Bad News

    https://subscriptions.boards.ie/



Comments

  • Registered Users, Registered Users 2 Posts: 1,653 ✭✭✭m_stan


    What's in and what's out in terms of features on the server side - ie: do you have PHP/ASP/JSP ? Do you want the file stored in a database or on a filesystem ? What interface do you need on the client side - html form/flash drag-n-drop interface etc ?

    Providing these details will help people answer the question better.


  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    If its php your using i have some code i can give yo that i've just used.


  • Registered Users, Registered Users 2, Paid Member Posts: 34,487 ✭✭✭✭~Rebel~


    If its php your using i have some code i can give yo that i've just used.


    Hi Bananna man, yeah that would be perfect! I havent used php yet but will be putting in something basic.

    Thanks!

    Subscribe to save Boards.ie from closing down: The Bad News

    https://subscriptions.boards.ie/



  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    Maybe try a Java based upload yoke to save your head on coding if you're not familiar with asp/php etc.

    eg: http://jupload.sourceforge.net/


  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    Have you a programming background? PHP has a large learning curve.

    Anyway, here's the code:

    HTML upload file page:
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    <input name="uploadedfile" type="file" class="main_text" size="70" />
    

    PHP script:

    [PHP]//Document Upload

    // Where the file is going to be placed
    $target_path = "../documents/";

    $target_path = $target_path . basename( $_FILES);

    if(move_uploaded_file($_FILES, $target_path)) {
    echo "<p class='main_text'>The file <span class='headings_red_large'>". basename( $_FILES).
    "</span> has been uploaded.</p>";
    } else{
    echo "<p class='headings_red_large'>There was an error uploading the file, please try again!</p>";
    }

    $sql = "INSERT INTO mysql_table_name
    (mysql_table_field)
    VALUES
    ('".basename( $_FILES)."')
    ";

    $results = mysql_query($sql)
    or die(mysql_error());[/PHP]

    You will need to setup a folder where the file will be saved. Put this folder name into target path. I have named it ../documents/ in this example. You will also need to chmod the folder to 777 so that the server can write into the folder.

    I have also added a mysql query to add the file location to my database for when i want to output it on my site. It's all just based on the move_uploaded_file() function

    let me know if you have any questions about it.


  • Advertisement
  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    That Java one I linked to might be a bit difficult to setup if your not used to Java - but theses should be a bit more manageable:

    http://www.jumploader.com/index.html
    http://www.jupload.biz/content/view/17/36/

    See the related documentation on each site to assist in your setup.


  • Posts: 1,882 ✭✭✭ [Deleted User]


    HTML upload file page:
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    <input name="uploadedfile" type="file" class="main_text" size="70" />
    
    You'd better make sure this code is inside a form like this:
    <form action="the_script_he_posted.php" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    <input name="uploadedfile" type="file" class="main_text" size="70" />
    <input type="submit" value="Upload File" />
    </form>
    
    The multipart/form-data is required for any forms submitting files.


  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    Ahh yes, good point!!


Advertisement