piece of source that reads in a blob from a form (<input type=file>)

From: Date: Mon, 23 Oct 2000 12:06:04 +0000
Subject: piece of source that reads in a blob from a form (<input type=file>)
Groups: php.windows 
Request: Send a blank email to php-windows+get-3450@lists.php.net to get a copy of this message
Can someone help me with a piece of source that reads in a blob from a form (<input type=file>) into a database field (p.e. a gif file). And a piece of code that retrieves the blob from the database and show the gif in the browser. Here is code for retrieving file <CENTER> <FORM NAME="insert" ENCTYPE="multipart/form-data" action="upload.php3" method=POST> <INPUT NAME="content" TYPE="file"> <INPUT TYPE="SUBMIT" NAME="f_submit" VALUE="Send"> </FORM> <?php echo "<TABLE BORDER=1><TR><TH>temp name</TH><TD>$content</TD></TR>", "<TR><TH>orig name</TH><TD>$content_name</TD></TR>", "<TR><TH>size</TH><TD>$content_size</TD></TR>", "<TR><TH>type</TH><TD>$content_type</TD></TR>", "</TABLE><BR>"; $content=stripslashes ($content); $file=fopen($content,'r'); while ($buffer = fgets($file, 4096)) { echo $buffer; } fclose($file); echo "</XMP></TD></TR></TABLE></CENTER>"; } ?> before insert in DataBase you have to AddSlashes and you have to save $content_type in separate column. On retrieving picture You have to output in first line and character of php file: <?php echo "Content-Type:$content_type\n\r\n\r"; echo ....Picture Content from DataBase.... ?> But if You ask me I prefer puting picuture in some file and saving only file name in Base. It increase efficiency of application cause picture does not have go throw DataBase and PHP. Sasha Rudan

« previous php.windows (#3450) next »