Hi all,
i use this script in PHP 5 to upload the file into a blob field:
And i use this script to download the file:
This sample code does not work with jpg or exe files. Works fine with doc, xls, txt.
Any help on that?
thanks anyway.
i use this script in PHP 5 to upload the file into a blob field:
Code:
...
$binfile= $_FILES["binfile"];
$binfile_name= addslashes($binfile["name"]);
$binfile_tmp_name= addslashes($binfile["tmp_name"]);
$binfile_size= $binfile["size"];
$binfile_type= $binfile["type"];
$filedata = base64_encode(fread(fopen($binfile_tmp_name, "rb"), filesize($binfile_tmp_name)));
...
$query= "insert into `downloads`(`fileid`,`description`,`filename`,`filesize`,`filetype`,`filedata`,`uploaddate`) "
."values ('', '$description','$binfile_name','$binfile_size','$binfile_type','$filedata',NOW());";
...
And i use this script to download the file:
Code:
...
$fileid= $_GET["fileid"];
$query= "select * from downloads where fileid= $fileid;";
$result= mysqli_query($db, $query);
$row= mysqli_fetch_array($result);
$data = base64_decode($row["filedata"]);
$name = $row["filename"];
$size = $row["filesize"];
$type = $row["filetype"];
...
Any help on that?
thanks anyway.