joebudden Posted December 19, 2006 Share Posted December 19, 2006 hi, i am writing a script enabling users to upload files to a mysql database so far my application enables users to: login logout upload files display uploaded files delete uploaded filesmodify file namesWhat i want to do now is allow the user to view the files in the browser ie jpgs word documents etcthis is what iv done so far ..<?php//connection to mySql $con = mysql_connect("localhost","root","")or die ("Error: " . mysql_error());//database matchdb is selectedmysql_select_db("p03293858db",$con)or die ("Error: " . mysql_error());$selectfrmdb = "select filename,type,size,content "."from artefact where artefactId='".$_GET['id']."'";$result = mysql_query($selectfrmdb,$con)or die('Error, query failed');list($filename,$type,$size,$content) = mysql_fetch_array($result);echo '<img src="$content"></img>';mysql_close($con);exit;?>any ideas ???? Link to comment https://forums.phpfreaks.com/topic/31260-downloading-files-from-mysql-database/ Share on other sites More sharing options...
thepip3r Posted December 19, 2006 Share Posted December 19, 2006 is your current code working?? if so, the download would be simple. just make a hidden form field with the same variable $content as it's value and then make a submit button on each page. Then just make code on your page to check for that submit button's press, grab the value of the hidden form field and then look up force file download tutorial on how to push the file to the user.example[code]if ($_POST['download']) { #if that's the name of the button you choose if ($_POST['hidden_content']) { #input code for pushing file to user }}<input type=\"hidden\" name=\"hidden_content\" value=\"$content\"> [/code] Link to comment https://forums.phpfreaks.com/topic/31260-downloading-files-from-mysql-database/#findComment-144621 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.