I am new to this and I am really stuck on how to download a file I have managed to upload on my local server.
My uploaded script is -
require_once ('dbcon.php');
if(isset($_POST['log'])){
foreach($_FILES['files']['tmp_name'] as $key => $name_tmp){
$file = $_FILES['files']['name'][$key];
$tmpnm = $_FILES['files']['tmp_name'][$key];
$type = $_FILES['files']['type'][$key];
$size = $_FILES['files']['size'][$key];
$dir = "file/".$file;
$move = move_uploaded_file($tmpnm, $dir);
if ($move){
$query = ("INSERT into dfile VALUES(null,'$file','$type','$size')");
$result = $dbLink->query($query);
if($result){
echo "<h4>Upload Complete</h4></br>";
}else{
echo "Error Table DB";
}
}
}
}
You do this, by setting headers:
Be sure that the
Content-Type
is a MIME-Type. You could put this code in a seperate filedl.php
and call it like this in your view:SomePage.php
download.php
The path depends on the structure of your scripts but basically it will go like this :