Hello to everyone,
I have a mysql table

CREATE TABLE `tools_domuments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `filename` varchar(255) CHARACTER SET utf8 NOT NULL,
  `description` longtext CHARACTER SET utf8 NOT NULL,
  `filetype` varchar(255) CHARACTER SET utf8 NOT NULL,
  `document` longtext CHARACTER SET utf8 NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

In the column 'document' I am inserting the content of the files encoded with Base64Encode. I am doing this with an desktop app.
My issue is that I want a php file that when I execute it, to download a file that is stored in a specified row.
I have tried some samples but with do success.
Could someone help me with this?!

Can we see at least ONE of those script samples? Maybe it just need minor tweakings.

Normally, if the query is successful, we can decode the row document like this

echo base64_decode($row['document']);

Thank you for your reply.
Here it is the code that I was testing:

<?php
    require_once("config.php");

    $item_id = stripslashes($_GET['item_id']);
    $item_id = mysql_real_escape_string($item_id);  
    settype($item_id, "integer");
    if ( $item_id < 1 ){
            include_once('error_sqli.php');
            exit();
    }

        $query = "SELECT tools_domuments.filename, tools_domuments.filetype, tools_domuments.document FROM tools_domuments WHERE tools_domuments.id = '$item_id';";       
        $result = mysql_query($query) or die('Error, query failed');
        list($name, $type, $content) =  mysql_fetch_row($result);
        $content = base64_decode($content);
        $type    = base64_decode($type);
        $name    = base64_decode($name);

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

?>

I will also try the command that you suggested to me.

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.