Re: Uploading file into database

From: Date: Fri, 13 Apr 2001 01:24:13 +0000
Subject: Re: Uploading file into database
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8537@lists.php.net to get a copy of this message
Hi, ok, first of all make sure your form tag is like : <form method="POST" name="ImageForm" action="UploadImage.php3" ENCTYPE="multipart/form-data"> The ENCTYPE is important! Next, make sure you have a field like: <input type="file" size="50" name="txtImage"> type="file" is important! This will present a browse button for the user to browse their drives something like this seems to work - drop the addslashes if it is not a binary file, such as an image ------------------------ $filecontents = addslashes(fread(fopen($txtImage, "r"), filesize($txtImage))); $thisfiletype = $txtImage_type; $db = mysql_select_db("somedb", $someconnection) or die ("db"); $sql = "INSERT INTO Images (..all the fields...) VALUES ('$filecontents',...and all the rest of the fields')"; $sql_result = mysql_query($sql,$someconnection) or die ("could not insert into DB"); mysql_close($someconnection); ---------------------------------------------------------- Hope this helps.. Phil J. Zeus wrote: > I'm trying to do a filexchange script. > > Does anyone know how to upload a file into the database such that when I do a 'select > *' query, I can click on a link the download that file.

« previous php.db (#8537) next »