Home All Groups Group Topic Archive Search About

How to upload files to a remote webserver using FileUpload ?

Author
18 Apr 2006 8:14 AM
Prasath
We are able to upload files to a localhost .  How to make it working for a
remote web server ?

Thanks

Author
20 Apr 2006 3:57 AM
Nathan Sokalski
To save a file from a client to a webserver, do the following:


1. Include an HTML Input tag similar to the following in your .aspx file:

<INPUT id="fileNewsNotes" type="file" size="50" name="fileNewsNotes"
runat="server">


2. Use code such as the following to manipulate the PostedFile.FileName
property and PostedFile.SaveAs method to save the file to the server:

Dim dir As String() =
fileNewsNotes.PostedFile.FileName.Split("\".ToCharArray())

Dim upfilename As String = dir(dir.GetUpperBound(0))

fileNewsNotes.PostedFile.SaveAs(Server.MapPath("pdf/") & upfilename)


PostedFile.FileName refers to the text that you see in the HTML input
type="file"    This string must be split, because you normally only want the
name of the file, not the location on the client's machine. In the code I
have above upfilename is the name of the file that is being submitted. In
the last line, I call the SaveAs method which saves the file to the server.
The parameter is the location that you want to save the file to. When
specifying this parameter, it is usually best to use the Server.MapPath()
method concatenated with the filename so that you can specify the directory
as a relative directory. If you have any questions, feel free to ask. Good
Luck!
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"Prasath" <r_pras***@hotmail.com> wrote in message
news:%23JTJWAsYGHA.1220@TK2MSFTNGP02.phx.gbl...
> We are able to upload files to a localhost .  How to make it working for a
> remote web server ?
>
> Thanks
>