psathish2 -6 Junior Poster in Training

downloaded file show only 0byte nothing in download file...............


this file uploading codes...


Code:fileload.html

<html>
<head>
</head>
<body>
<center>
<form method=post action="loadfile.php" ENCTYPE="multipart/form-data">
<h4>Enter the Following Details</h4>
<table border=1>
<tr>
<td>
Enter FolderName</td><td><input type="text" name="fname">

</td>
</tr>
<tr>
<td>
Title</td><td><select name=title>
  <option value ="resume">resume</option>
  <option value ="resume1">resume1</option>
  <option value ="resume2">resume2</option>
  <option value ="resume3">resume3</option>
  <option value ="att">Attendance</option>
</select>

</td>
</tr>
<tr>
<td><INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000"> 
Upload</td><td><input type="file" id="file" name="uploadingfile">
</td>
</tr>
<tr>
<td>

</td><td><input type="Submit" name="insert" Value="Submit">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>

uploading file into db..

Code:loadfile.php

<?php

$fold=$_REQUEST['fname'];
$title=$_REQUEST['title'];
$uploadedfile=$_REQUEST['uploadingfile'];

$host="localhost";
$user="";
$pass="";
$dbid="upload";
$link=mysql_connect($host,$user,$pass);
mysql_select_db($dbid);

$path="hi/". $_FILES['uploadingfile']['name'];
echo $path;
		
move_uploaded_file($_FILES['uploadingfile']['tmp_name'],$path);

mysql_query("insert into loading(folder,title,fileload) values('$fold','$title','$path')");

mysql_close($link);


?>

this page userpage if click the link download the file...

If click the link particular file download to selected location. And if open the downloaded file 0byte nothing is in downloaded file... plz help me..

Code:userlink.php

<html>
<head>
<head>
<body>
<center>
<br>
<?php
$id=$_GET[id];
$host="localhost";
$user="";
$pass="";
$dbid="upload";
$link=mysql_connect($host,$user,$pass);
mysql_select_db($dbid);

$query = "SELECT id,folder,title,fileload FROM loading";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "Database is empty <br>";
}
else
{
echo "<table border='1' width='400'>
<tr>
<th>Id</th>
<th>Titles</th>
</tr>";
while($row= mysql_fetch_array($result))
{
$id=$row['id'] ;
$folder=$row['folder'] ;
$load=$row['fileload'] ;

echo " <tr> ";
  echo "<td>" . $row['id'] . "</td>";

echo "<td align='left'><a href='download.php?id=$id'>$folder&nbsp;</a>"; 
echo "</tr>";

}
}
echo "</table>";
mysql_close($link);
?>
</center>
</body>
</html>

this download code

Code:download.php

?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database

$host="localhost";
$user="";
$pass="";
$dbid="upload";
$link=mysql_connect($host,$user,$pass);
mysql_select_db($dbid);

$id    = $_GET['id'];
$load=$_REQUEST['load'];
$query = "SELECT fileload " .
         "FROM loading WHERE id = '$id'";

$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);

header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
echo $content;

mysql_close($link);

exit;
}

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.