Webboy2008
asked on
asp.net / upload
I have aspx webpage to allow user upload document. and that is working fine.
once the document is uploaded and saved into like C:\\Tmp\\doc.pdf
How can I open it on the web.
once the document is uploaded and saved into like C:\\Tmp\\doc.pdf
How can I open it on the web.
To copy the file you'll need the physical path FROM and TO
You already know FROM - "C:\\Tmp\\doc.pdf"
The TO will be a function of HttpContext.Current.Server .MapPath
MapPath will help you get the PHYSICAL directory path to your website.
Let's say you make a subdirectory under your website named "MyTmpHoldingArea"
The copy-TO destination is
Dim CopyToDPFE As String = HttpContext.Current.Server .MapPath(" ~/MyTmpHol dingArea/d oc.pdf")
File.Copy(FROM, CopyToDPFE )
You may also need Path.Combine() if you're unsure of how to assemble the paths and file names properly.
Dim DPFE As String = HttpContext.Current.Server .MapPath(" ~/UserAcce ssWithdraw Template.h tm")
You already know FROM - "C:\\Tmp\\doc.pdf"
The TO will be a function of HttpContext.Current.Server
MapPath will help you get the PHYSICAL directory path to your website.
Let's say you make a subdirectory under your website named "MyTmpHoldingArea"
The copy-TO destination is
Dim CopyToDPFE As String = HttpContext.Current.Server
File.Copy(FROM, CopyToDPFE )
You may also need Path.Combine() if you're unsure of how to assemble the paths and file names properly.
Dim DPFE As String = HttpContext.Current.Server
Opps ... last line in last post was accidentally copied too!
Please ignore.
Please ignore.
ASKER
I have c# in asp.net and I don't really understand what you are trying to tell me.
The directory (c:\\tmp\document.pdf) already in one of the database table.
I will be able to get string like "c:\\tmp\\document.pdf.
Can you try to show me the working codes? Thanks
The directory (c:\\tmp\document.pdf) already in one of the database table.
I will be able to get string like "c:\\tmp\\document.pdf.
Can you try to show me the working codes? Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Only you'll encounter a problem. Because, for the file to be accessible from your website, it must FIRST exist on a directory which the website has access to. I doubt your website has access to "C:/" ... right?
So,
(A) define a subdirectory under your website directory structure
(B) copy the file from "C:\\Tmp\\" to your new subdirectory
(C) use Response.Redirect(newdirec