Hi,
I am currently in my final year doing an eportfolio system as my final year project and this system will allow students to do things such as upload images, academic documents in say word,pdf files. Also it would allow students to set privacy issues to each document in their page. Say for example if i upload one file to my page, the person can set that document to be viewed by certain people. the user groups i have is,public,private,registered users and special people.

I just want to ask anyone out there if you have any php script that can help me upload music $ video files to my database and be able to download them. the script i have does upload them but i dont know when it comes to downloading them it doesn't download the files successfully.

also i am finding it difficult to implement a database design for the privacy issues i explained above.

say for instance someone sets a particular document to be viewed only some special people, how do I implement this in the database. My idea is that if someone sets a document to special people, that special person is created and then there will be a table that will created just for special persons that people have created and then there will be another table that lists all the documents be it word,image,video files etc and with the respective people that can view them.

If anyone has done this before please can u help me out by giving a suitable database design or explanation on how to go bout this.

first. create dropdownlist which contains details about privacy.. assign an id and create a table about uploading to store paths and uploaders' id, privacy etc.

1 > Public
2 > Private
3 > Registered

as you upload the file ask uploader to set its privacy level... and save the file path to your db and upload the file.. thats all.

while people browsing check that privacy id and do whatever you want...

Hello,

Uploading The File :
1. uploade the file and stored this info in a database
i. fileID (a unique identifier -this can get autogenerated )
ii. filename - mySong.mp3 (use this cmd = $_FILES )
iii. file path - where the file is stored (e.g. \web_root\uploadedFile\)
iv.file full path - (eg \web_root\uploadedFile\mySong.mp3)
v. file Size - in bytes (use this cmd = $_FILES )
vi. file type - (e.g. mp3, doc, mov,pdf) (use this cmd = $_FILES )

* note that $_FILE; the first 'file' param is the name you gave your file box = <input type="file" name='file' />

* also note that the "file path field may not be usefull unless you want to do more processing with your application by dynamically specifying different paths

To download an uploaded file (say mySong.mp3) you might do this

1. List the uploaded file on your web page with an <a> tag. e.g <a href='downloadPage.php?id=$uploaded_fileID > $uploaded_file_name <\a>
2. use a GET method to retrieve the $uploaded_fileID from the browser. use the ID to retrieve the following from the DB
i. $filename - the File you want to download
ii. $type - the file type you are downloading
iii. $size - the file size
iii. $fileFullPath= (eg \web_root\uploadedFile\mySong.mp3)

3. create an header file that will allow activate the download functionality; then download the file. See Below

header("Content-Disposition: attachement; filename=$filename");
header("Content-type: $type");
header("Content-length: $size");
header("Content-Description: www.myuploadDownloadSite.com music and Videos");

== the above code will set yout browser to download files
=== now use fopen to donwlad the file

$fp= fopen($fileFullPath,'r'); == open the fill mySong.mp3 using the full path name
$content=fread($fp,$size); === read the file to a variable called $content
echo $content; === display the file read - this should display some scripted stuff on your browser but because you have specified the "headers" above, it will not display it on your browser. It will bring out a dowload dialog box for you.

Hope this will solve your problem.

hi i know the code for all upload

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
 <form enctype="multipart/form-data" action="upload.php" method="POST">
 Please choose a file: <input name="uploaded" type="file" /><br />
 <input type="submit" value="Upload" />
 </form> 
</body>
</html>

-------------------another file

<?php 
 $target = "upload/"; 
 $target = $target . basename( $_FILES['uploaded']['name']) ; 
 $ok=1; 
 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
 {
 echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
 } 
 else {
 echo "Sorry, there was a problem uploading your file.";
 }
 ?>

Edited 6 Years Ago by nav33n: Please use [code] [/code] tags to wrap your code for easy readability. Also check the date before posting.Welcome to Daniweb!

help me

how do yo do for upload video and convert to flv ????

mail : [snipped]

Edited 5 Years Ago by Ezzaral: Snipped email. Please keep it on site.

i have been trying to upload music with the above code but the file will not upload but all the picture upload are successfully .

i need some help here i want to upload music file to a directory in my server but i have been having problems with it.

This article has been dead for over six months. Start a new discussion instead.