Click to See Complete Forum and Search --> : Database
chris9902
12-27-2003, 05:43 AM
I want to make a online database. What i want is for people to be able to upload a file and add a description.
so you have a form like;
Your Name:
Date Added:
Description:
File:
and when you have filled out the form and uploaded your file, the file goes to a folder on my server. Then all the information is dsiplayed on the site with a link to that file.
?? did that make sense ??
if so how would i do something like this?
Sux0rZh@jc0rz
12-27-2003, 03:02 PM
you'd use mysql... create 4 fields and name them accordingly and set their properties to allow for the info and whatnot. then have a page that displays results from the mysql database...
chris9902
12-27-2003, 04:49 PM
i think i am ok in doing that but it is the file apart i don't understand.
how could i make the file go to /files and also how that could be displayed using mySQL
maybe if it change the file name on upload to coninside with the ID (ie. 1.zip, 2.zip) and then it is displayed like that.
i really don't know how you even start something like that
Sux0rZh@jc0rz
12-27-2003, 07:16 PM
do you have to have the files be added there or can you just query the database directly and skip that file step?
EDIT: instead of having mysql send the file to your server and then have a page read the files, you could just have the page query the database directly. do you wish to do this or must you have the files sent from mysql to your server?
Here's half of it:
http://forums.webdeveloper.com/showthread.php?s=&threadid=10236#post53379
chris9902
12-28-2003, 07:05 AM
ok, i have the file part done now. i can upload the files and then have a different page display whats inside that folder.
this is the page that displays links to the files inside my upoad folder. saved as view.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?
$path = "upload";
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "Directory Listing of $path<br/>";
while ($file = readdir($dir_handle)) {
echo "<a href=upload/$file>$file</a><br/>";
}
closedir($dir_handle);
?>
</body>
</html>
this is the form to upload the files
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
Select a file to upload! <input type="file" name="userfile"><br>
<input type="submit" value="Upload!">
</form>
and this is the php that uploads the files
<?php
if(!(copy($_FILES['userfile']['tmp_name'], "upload/" . $_FILES['userfile']['name']))) die("Cannot upload files.");
echo "Upload Complete!";
?>
but somehow i would like the file to be displayed in some sort of table with text next to it. i think i could make a 2 cell table and send the text to mySQL and the file to the folder then call the text from it's ID and the file from when it was uploaded so it should display file and text next to each other.
????????????????????