Mira esto hice con mysqli y me anduvo muy bien:
Carga:
Código PHP:
Ver original<?php
//Config
$d = "dir/subdir"; //Direction without / final
"server" => "server", //DB server
"user" => "user", //DB user
"pass" => "pass", //DB pass
"db" => "db", //Data Base
"table" => "table" //DB table
);
//End config
$mysqli = new mysqli($db_data["server"], $db_data["user"], $db_data["pass"], $db_data["db"]);
for($k=0;$k<sizeof($dir);$k++){ if($dir[$k] != "." && $dir[$k] != ".." && !is_dir("$d/".$dir[$k])){ $file = "$d/".$dir[$k];
$name = $dir[$k];
$data = $mysqli->real_escape_string(fread($fop,$size));
$mysqli->query("INSERT INTO ".$db_data["table"]." (name, size, mime, data) VALUES ('$name', '$size', '$mime', '$data')");
}
}
?>
Download:
Código PHP:
Ver original<?php
$idFile = 3; //someway to get the id of file
//Config
"server" => "server", //DB server
"user" => "user", //DB user
"pass" => "pass", //DB pass
"db" => "db", //Data Base
"table" => "table" //DB table
);
//End config
$mysqli = new mysqli($db_data["server"], $db_data["user"], $db_data["pass"], $db_data["db"]);
$file = $mysqli->query("SELECT * FROM ".$db_data["table"]." WHERE id='$idFile'")->fetch_assoc();
$name = $file["name"];
$size = $file["size"];
$data = $file["data"];
header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$name.'"'); header('Cache-Control: must-revalidate'); header('Content-Length: '.$size); echo $data;
?>
Y mi tabla:
id: primary ai
name: varchar
size: int
mime: varchar
data: longblob
Tu dale la longitud y cotejamiento a toda la tabla
Eso, falta las validaciones, pero espero haber ayudado.
Saludos