Results 1 to 5 of 5

Thread: Upload files and add to SQL?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    32

    Talking Upload files and add to SQL?

    Hi, I'm coding a LUA addon for a game, I'm streaming music to the game through my web server, and the list of songs is in a database with the fields: name, artist, album, min, and sec. I've managed to make a PHP script that adds those fields to the database, but then I have to go into the FTP, add the file in exactly the right place, etc. I was wondering if I could get some pointers on how to make an upload script that would take the fields I put in for the database, and make it upload to that directory, and add to the database at the same time. And example would be

    Name: Test Song
    Artist: That one guy
    Album: The best one ever
    Minutes: 3
    Seconds: 24

    Then I'd pick an mp3 and press 'Submit'. It would then upload that file to /That one guy/The best one ever/Test Song.mp3

    I'd feel bad asking for someone to just hand me the code, so I'm asking for some good tips. I'm new to PHP and fairly new to SQL, and I'm sure this is pretty complicated, but any help would be greatly appreciated! Thanks in advanced

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Upload files and add to SQL?

    Here is a tutorial for creating a file upload script:

    http://www.w3schools.com/PHP/php_file_upload.asp


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    32

    Re: Upload files and add to SQL?

    I got the file upload working, but I also need it to change where it uploads and add to the database. I put the database script in the upload script, and it gave me errors all over. Not sure why.

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Upload files and add to SQL?

    well, if you have a script that you add songs to the database with already, you can just add a file upload to it and then save the file like that. you just have to create the directories, if they don't already exist, and then save the file in them. I'm not sure what you meant by "put the database script in the upload script," but if you meant it literally, then of course there would be errors! post some code.

  5. #5
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: Upload files and add to SQL?

    When you upload the file, record the file's path into a database.

    I would also name the file something like:

    Test_Song_currenttimestamp.mp3 and save that file name into the database to avoid writing over your current files.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width