Re: [PHP-DB] Uploading file into database

2001-04-12 Thread Phil Jackson

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.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Uploading file into database

2001-04-11 Thread Lucio Stoco

Have you done the file upload into the database?
I´m having some problem to put the file (like .doc or .xls) in a database...
I´m using 'text' field type, is it right?

Do you have any example about it?

Tks.

""Zeus"" [EMAIL PROTECTED] escreveu na mensagem
01e601c0c26e$6ccded80$735518d2@zeus">news:01e601c0c26e$6ccded80$735518d2@zeus...
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.





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]