Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 The Yak Corral
 Upload and download the file into database

Author  Topic 

sucithra
Starting Member

7 Posts

Posted - 2010-10-08 : 05:26:26
hi

i want to upload a files(image,pdf,doc and xls )into sql server database.

i created a tabel with 4 fields(file_id,file_name,file_type,file_size and file content)

id and file size is int, file name file type varchar

and file content is "image"

i used this code

$tmpName =$tmpName = $_FILES['file']['tmp_name'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);

and insert the value into the table(fileid, filename,filetype,filesize,$content);

it stored as some binary data...

when i trying to download "file corrupted " msg is coming or some binary value is displaying in the doc file.

i include the headers also..

Thanks in advance very urgent..give me some soulution

cithra

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-10-08 : 06:27:28
Posted in the wrong place.

Please either report in the relevent forum for your sqlserver version 2000 / 2005 / 2008 or ask a mod to move it to a forum of your choice.

This is the "social" forum. No work here please.

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -