Jump to content

Online Inventory System Question


kre8tiveart

Recommended Posts

I have been watching the PHP tutorials and they are great.

 

I am currently a student and we have to create an "online inventory system", using our computer as a server and host instead of an actual host online. We have to let the users REGISTER an account, UPLOAD FILES and RETRIEVE THE FILES. I have been watching the PHP videos. I have set up the LOGIN SYSTEM using the video you did for login and now i need to know which videos to watch to learn how to create a directory for the newly registered user and display items from their directory after they upload items, on a page after they login. I appreciate your time and help. thanks!

Link to comment
Share on other sites

Unfortunately I'm pretty sure this isn't something that we cover in a tutorial, though I have meant to do a tutorial on upload functionality. I just have to find the time.

 

Google is probably going to be your best friend for this one. Just Google "create folder php" and "upload file php" and I am sure you will find a lot of tutorials to help you out. And of course you are welcome to post if you need help.

Link to comment
Share on other sites

  • 2 weeks later...

Ok thanks. I found a way to upload the files to a directory and also how to read into the directory and display the

files from the directory using this function:

 

<?php

if ($handle = opendir('.../uploads')) {

while (false !== ($file = readdir($handle))) {

if ($file != "." && $file != "..") {

echo "$file\n";

}

}

closedir($handle);

}

?>

 

Also, I can download a particular file from directory using this function

<?php

$file = '...upload/Thumb.png';

 

if (file_exists($file)) {

header('Content-Description: File Transfer');

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment; filename='.basename($file));

header('Content-Transfer-Encoding: binary');

header('Expires: 0');

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

header('Pragma: public');

header('Content-Length: ' . filesize($file));

ob_clean();

flush();

readfile($file);

exit;

}

?>

 

I would like to know how I can display the items from the directory, in a list. And each item

has a link that, if pressed can be downloaded. THANKS ALOT FOR YOUR HELP!

Link to comment
Share on other sites

Do you specifically have to do it in that way?

 

What i would do is have it database driven and allow users to upload files to a table in the database, that would hold user id, file name and file type. You can set it up the file name so it's saved with a prefix of the users name/id. So when a user uploads a file it is saved to folder on the server and the information about the file is held in the db. Then you can query the db so a user can access their files. This way you don't have to setup a folder for each user and everything is kept seperate by saving the users id/username in the files table

Link to comment
Share on other sites

ok thats sounds great.

 

I'm thinking that this would make it easier for me to display the files for the users, with option of downloading or deleting there files.

My question now is how can I go about coding all of what you said? Could you help me with the coding instruction.

After registering I just made a directory with the users username before. but I don't know how to code the

process of upload to table in database(MYSQL) prefixed with username/id. And then read from there.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...