PHP /username/custom-uploaded-file-url

Discussion in 'Programming Languages' started by HTML, May 15, 2015.

  1. HTML

    HTML Big Board Coder

    259
    125
    +36
    Hello,

    I am working on a website where users can upload audio files, and those audio files are then displayed as a list on their profiles, "johndoe" being my username... (mysite.com/johndoe)

    How can I make this work? - I need a text box that a user can type in what they want the vanity url to be for that specific upload they are editing / in the process of being uploaded.

    For example, I uploaded audio file cool-drums.mp3. I type "cooldrumsclip" in a textbox for the custom url for that file. I save the form. Now, to visit this audio file, this would be the URL: mysite.com/johndoe/cooldrumsclip

    This is an example of my current audio file URLs: mysite.com/index.php&a=track&id=55 , 55 being the track ID.

    TL:DR:
    Basically, I need to allow the user to define a custom URL for uploads, and for that custom URL to appear after their username like so - mysite.com/johndoe/mycustomurlformyfile (the file URL is originally being index.php&a=track&id={fileID})
     
  2. Jake

    Jake Developer

    1,057
    362
    +1,109
    You'll need to make your PHP file accept the name instead of the id, and then use mod_rewrite for the rest.
     
  3. HTML

    HTML Big Board Coder

    259
    125
    +36
    Thanks for your reply. Well, that is obvious. That's the simple part, the other stuff isn't. I'll have to have the URLs be index.php?a=track&u=johndoe&track=audiotitle

    I'll probably have to have the username in there because if 2 users uploaded the same audio file with the same name, that wouldn't work out too well. I guess this is probably the wrong place to ask for help with this, but it was worth a shot :/
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.