Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Word Document Attachment on an asp page

Status
Not open for further replies.

uzzie123

Technical User
Mar 7, 2007
21
CA

Hi,

I want to create a word document attachment to my asp web page. So when a user clicks on this link, the specified word document should directly open. I was reading that the webbrowser control will assist in this process, but i am not too familiar with it. Can some provide me with any ideas that will help me get started. Thx.

 
You want the Word document to open directly in MS Word? Well, provided that Word is installed on the client machine, then if you provide a link to the doc it should open directly in Word.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Hey,

I did not explain it properly. I created this website where users can add new records. In each of those records, the user should have the option to attach a word document. So i Basically created an input control that allows the user to browse and find the file they want attached to their record. Now the problem is, I have to create a link of the file (in the records page) that the user requested to be attached while adding a new record. In order to do this, I have to create a FileSystemObject object. But then I am not too sure of how to do the rest? I hope this is clear.

 
Do you have a script or object already to handle the file upload? I generally stick with pure ASP file upload scripts, but the one thing you need to make sure a selected script has is the ability to access other form fields, as ASP won't let you access them once a file upload script starts binary reading the file data that was uploaded.

Basically what you will want to do is:
1) Read in the file using an upload script
2) save it somewhere in the web path so it's accessible by URL, make sure the name isn't in use beforehand and/or change the name to something unique (you can use the FileExists method of a FileSystemObject to determine this)
3) setup your db connection
4) insert the other values that have been posted and the name of the file that was uploaded and saved locally

When you need to display a link to the file you simply output a URL that consists fo the web path to the folder your uploading files to, appended with the filename from the database. By only storing the filename you also gain some flexibility in that if you ever move your files to a new folder all you have to do is change the base URL in your code rather than all the records in your database.

Hope that helps,
-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top