Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

File upload to website advice?

Options
  • 20-09-2007 4:16am
    #1
    Registered Users Posts: 31,730 ✭✭✭✭


    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!


Comments

  • Registered Users 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 Posts: 673 ✭✭✭Bananna man


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


  • Registered Users Posts: 31,730 ✭✭✭✭~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!


  • 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 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: 0 ✭✭✭ [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 Posts: 673 ✭✭✭Bananna man


    Ahh yes, good point!!


Advertisement