Home Answers Viewqa PHP why my downloaded file is alwayes damaged or corrupted?

 
 


Vidhi Singh
why my downloaded file is alwayes damaged or corrupted?
0 Answer(s)      3 months and 13 days ago
Posted in : PHP

This is my code
<html>
<form action='../biopydb/new.php' method='post'>
<?php

$Pathway_Name = $_COOKIE['pathwayname'];
$dir1    ="../biopydb/Pathway_Images/"."$Pathway_Name/";

$dirPath = dir($dir1);
$imgArray = array();
while (($file = $dirPath->read()) !== false)
{
  if ((substr($file, -3)=="gif") || (substr($file, -3)=="jpg") || (substr($file, -3)=="png"))
  {
     $imgArray[ ] = trim($file);
  }
}

sort($imgArray);
$c = count($imgArray);
for($i=0; $i<$c; $i++)
{
$value = "$dir1"."$imgArray[$i]";
echo "<input type='radio' name='group1'  value='$value' /> $imgArray[$i] <br/>";

}
?>
<br/><br/>
<center>
<input type='submit' value='Download'/></center>
</form>
</html>

new.php
<?php
$Pathway_Name = $_COOKIE['pathwayname'];
$dir1    ="../biopydb/Pathway_Images/"."$Pathway_Name/";

$filename = $_POST["group1"];

echo"$filename";

header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\"");
header("Content-Type: application/force-download");
header("Content-Length: " . filesize($filename));
header("Connection: close");
?>
View Answers









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.