Help with file upload and database information table...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mark Bowen
Forum Newbie
Posts: 13
Joined: Thu Sep 30, 2004 4:38 am
Location: United Kingdom | Birmingham

Help with file upload and database information table...

Post by Mark Bowen »

Hi there,

Sorry to keep on being a pain to everyone but I now have another question.

I have found what I think to be an excellent File Upload script at http://www.qto.com/fm/index.htm but would like to modify it in a couple of ways.


1 - I would like the username and password to be checked against a database table

The table would be called users and would have columns named :

A - id (Auto incrementing)
B - userName
C - password - (Using MD5 - I hope!!)
D - uploadFolder (Main folder for uploads)

However what I would like to be able to do (as I work in Flash and not HTML) is be able to verify a userName and password using Flash and PHP and if the supplied information is correct they will be logged into the system. I would then allow people to update information in a database and then if they would like to upload files if they then press on a button in the Flash movie and it would bring up this kind of script, however I would need the script to be generic as in I don't want to have to have the PHP file located in every users folder to allow them to use it. I would like to be able to pass the uploadFolder from Flash once they have been successfully logged in and then use this from within the file uploader to allow it to find the main folder.
I would then have four or so different folders within the hierarchy structure of say mp3, images, text and docs so that they can upload to different folders different types of files. I would then like to have some way of only allowing certain types of files into certain folders as Flash will then be loading in these files and if the wrong type of file is in the wrong folder then Flash could throw a wobbly!!

There is then a second part to all of this and I have absolutely no idea how to go about implementing this one.
I would like to be able to once a user has uploaded all the files that they want to is click on a button and be taken to a table styled layout of files they have uploaded and be able to choose a section for them to be listed in. Let's say that they upload three mp3 files and they want one of them to go into a section called main one into a section called gallery and one into a section called other then they would see the uploaded file names and using a dropdown be able to select the categoury. This would then be used to update a table in a database.

I was thinking that this might be even easier if the whole upload / table creation was put into one operation so they :

A - Login in Flash
B - uploadFolder variable is passed to a generic PHP script
C - Script queries a table in the database for all files previously uploaded by the user (if there are any).
D - Display information and allow categoury selection.
E - Update information or,
F - Upload a file into a certain folder (with file type checks) and choose categoury at same time and then refresh the table view in HTML. Also to go along with this if there could also be a delete file button which not only deletes the file from the server but also deletes the entry for that specific file in the database table.


I would still need the part in the script where it limits how much space they are allowed to upload to though.

I am sorry for such a long and involved post but if anyone can help me out with this then I would be in eternal debt to you.

Regards,

Mark Bowen
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

this sounds like a big enough list that you want someone to do it for you. however here are steps to each of your list:

Logging in
  1. You start by asking for username and password through Flash.
  2. When "submitted" you can have Flash make a behind the scenes page request to a script that checks if the username and password were indeed correct, and "logs them in".
user control panel
  1. The login script can return (to Flash) the user's data. Which you can make editable, and submit back to the server for update.
uploading
  1. having the upload script name the files unique names and storing them all in the same folder simplifies most of the stuff.
  2. having a table with the details as they pertain to the user (pooled with all the other uploaded file records) that's similar to this:

    Code: Select all

    original filename
    mime-type sent by browser
    your category to file them under (this would generally be a category id number, instead of a name.. 1. to save space.  2. to make it easier to create new categories and the drop down for them)
    the user id they are attached to (so other users can't get them)
    unique filename on server
    crc32 or other hash of the file (so you don't store copies of the same file)
Post Reply