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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Upload and download the file into database

Author  Topic 

sucithra
Starting Member

7 Posts

Posted - 2010-10-08 : 22:50:53
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

Sachin.Nand

2937 Posts

Posted - 2010-10-09 : 01:51:04
Isn't that more of a php issue than a SQL one?

PBUH

Go to Top of Page

sucithra
Starting Member

7 Posts

Posted - 2010-10-10 : 03:32:37
hi thanks

for your reply .


i like to store files(doc,pdf,xls and image ) into database ,

i am using sql server 2008 ,cso can you tell me what data type i should have to use...

thanks in advance
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-10-15 : 13:18:53
Please do not cross post, continue in this thread:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151372
Go to Top of Page
   

- Advertisement -