Jump to content

Jaswinder

Members
  • Posts

    1
  • Joined

  • Last visited

Jaswinder's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Note - my uploaded file goes into a folder name- songs i used the following code to upload :- In player.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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title></head> <body><form action="upload.php" method="post" enctype="multipart/form-data"><input type="file" name="i"/><input type="submit" value="Upload" /></form></body></html> In upload.php <? $i=$_FILES['i']['name'];copy($_FILES['i']['tmp_name'],"songs"."/".$i);$cn=mysql_connect("localhost","root","");$db=mysql_select_db("music",$cn);$a="insert into mp3 values('','$i')";$sql=mysql_query($a) or die(mysql_error);if($sql>=0){ echo "Successfully Entered";}else{ echo "failed";} ?><a href="show.php">show files</a> For downloading In show.php <?$cn=mysql_connect("localhost","root","");$db=mysql_select_db("music",$cn);$a="select * from mp3";$sql=mysql_query($a) or die(mysql_error);$n=mysql_num_rows($sql);if($n>0){while($f=mysql_fetch_array($sql)){?><table align="center" border="2" width="200" height="100"><td><a href="download.php?sno=<? echo $f['sno'];?>">Download</a></td></tr></table> <?} }else{echo 'No data';}?> In download.php<?php$download=$_GET['sno'];$cn=mysql_connect("localhost","root","");$db=mysql_select_db("music",$cn);$a="select songs from mp3 where sno='$download'";$sql=mysql_query($a) or die(mysql_error);$n=mysql_num_rows($sql);if($n>0){while($s=mysql_fetch_array($sql)){header("Content-type:audio/mpeg");header("Content-Disposition: attachment; filename='<? echo $s[songs]; ?>'"); i think here is the problem,.. not able to download files}} ?> Database name - musictable name - mp3fields - sno and songs Path to files - C:\xampp\htdocs\upload Path to songs folder where uploaded mp3 files go - C:\xampp\htdocs\upload\songs
×
×
  • Create New...