SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form with multiple actions

    I have a form where the entries on the form are getting saved to a database.
    That part works. however part of the form is for instructor to upload 4 documents.
    I want to files uploaded a folder on the website and the path to be saved in the db.

    How do i handle the file upload part of it. I have seen various posts, but I want the files to be renamed to a name made up of the users id and a few other session variables.

    Anyone?
    Thanks!

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This isn't about having multiple 'action' attributes on the form tag, so I would suggest you rename the thread to avoid confusion.

    It's really quite simple. First of all, you need to make sure you have an attribute in your form HTML tag called "enctype" with value "multipart/form-data". That will allow uploads to go ahead.

    Then, when you've checked if the form has been sent, you have full control over where you move their files to. There is no reason whatsoever that I can think of that you'd want to rename the files to anything special, because they're being saved in the database.

    So all you really need to do is give them a completely random name, and anyone who wants to access them could access them by getting the filename from the database based on a given clause.

    The first thing you really, really need to do is just play around with file uploading. No book, forum post or tutorial will give you a complete understanding of how to use everything, just like words cannot help someone to ride a bike. You need to try it out, play around with it and see what it can do and THEN work out how to implement it.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •