Re: connect to FTP server



re:
I didn't specify that directory

Clearly.

That's why I suggested that you *do* specify it.


private void Page_Load(object sender, System.EventArgs e)
{
/*
* Set the "path" variable to the location where files are to be stored
*/
string path = "../docs";

HttpFileCollection files;
files = Page.Request.Files;
for(int index=0; index < files.AllKeys.Length; index++)
{
HttpPostedFile postedFile = files[index];
string fileName = null;
int lastPos = postedFile.FileName.LastIndexOf('\\');
fileName = postedFile.FileName.Substring(++lastPos);
//Check the file type through the extension
if(fileName.EndsWith("doc") || fileName.EndsWith("doc") ||
fileName.EndsWith("pdf") || fileName.EndsWith("pdf")
{
postedFile.SaveAs(MapPath(path + "/" + fileName));
}
}
}



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CSharpguy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7759E6DD-C770-4C01-9CA9-C07CDAA88D43@xxxxxxxxxxxxxxxx
I didn't specify that directory, when I was trying to pull down the file it
tried and dump it there. I have an upload directory I'm working on pulling
the files from

"Juan T. Llibre" wrote:

re:
when I try and download a file I get "access denied to c:\windows\system32\ftptest.txt"

You need to specify a directory which isn't security-conscious
as the destination for the uploaded files.

I'd *never* upload files to that directory.

Also, if you're getting "access denied", the account ASP.NET is running as
doesn't have enough permissions to access the file and/or directory.

Save the following code as "identity.aspx" and run the file.

identity.aspx
=========
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
======

Then, assign access permissions for the file/directory to the account which that file returns.

Remember to change the upload directory to an ad-hoc directory.
Don't use c:\windows\system32\ as your upload directory.




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CSharpguy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FEFFF6CD-00DE-49AA-B3D6-658E88E31443@xxxxxxxxxxxxxxxx
I'm using the code and I'm getting 'access denie to file c:\ftptest.txt"
file, or I get False returned. Do i need to do anything on my box other then
the code? I'm logged into the FTP server (via a gui) to see if my file is
getting uploaded and its not, also when I try and download a file I get
"access denied to c:\windows\system32\ftptest.txt"

whats missing

"Swanand Mokashi" wrote:

The sample code I attached should let you do that.

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services


"CSharpguy" <CSharpguy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CE5BE3DA-5716-46EF-B01D-522A2085C38C@xxxxxxxxxxxxxxxx
I'll consider that as well, but all I need to do realy is upload the file
then check to confirm it got there.

"Kevin Spencer" wrote:

I might mention that these should be construed as examples. I had to
write
an FTP client, and the Socket connection and related functionality is not
difficult at all. What *is* difficult is handling the various
network-related issues that can arise. For an FTP client to be robust, it
needs to have a lot of recovery functionality (retries, timers, etc)
built
into it.

Another issue is that some of the format of the returned data, such as
directory listing and system status, is not standardized, and can be
difficult to parse.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Juan T. Llibre" <nomailreplies@xxxxxxxxxxx> wrote in message
news:OzMOzjsaGHA.3444@xxxxxxxxxxxxxxxxxxxxxxx
Here's a full-featured, free, FTP Client Library, written in C# :

http://www.c-sharpcorner.com/UploadFile/danglass/FtpClient12062005053849AM/FtpClient.aspx

It's less than 6KB in size.

Here's another example :
http://www.hotscripts.com/Detailed/40607.html



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"CSharpguy" <CSharpguy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:456D9AFD-5B3C-456A-82E4-72EE27D26D8D@xxxxxxxxxxxxxxxx
I need to upload a file to an FTP server, can someone point me to some
code
that connects to an FTP server and uploads a file?
















.



Relevant Pages

  • Re: tried everything- cannot publish to web
    ... the path to the FTP server correctly, ... firewall, and/or a third party firewall included in a antivirus suite, or a ... looking at the instructions from Yahoo about how to upload your site, ... how to use their control panel to upload your files. ...
    (microsoft.public.publisher.webdesign)
  • Re: probls with file upload script... pls help
    ... upload files to an FTP server. ... the user is on the Web server where he accesses the upload page. ... Upload_Click runs VB.NET script that calls clsFTP ... FTP client to upload a file to an HTTP web application. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: connect to FTP server
    ... I didn't specify that directory, when I was trying to pull down the file it ... I'd *never* upload files to that directory. ... Juan T. Llibre, asp.net MVP ... I'm logged into the FTP server to see if my file is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IIS 6 FTP problem
    ... Why there is port 20, if my FTP server runs on default port 21? ... > and I assumed you got the 'succesful upload' msgs when uploading at local ... > Bernard Cheah ...
    (microsoft.public.inetserver.iis.ftp)
  • Re: connect to FTP server
    ... Remember to change the upload directory to an ad-hoc directory. ... asp.net faq: http://asp.net.do/faq/ ... I'm logged into the FTP server to see if my file is ... "Swanand Mokashi" wrote: ...
    (microsoft.public.dotnet.framework.aspnet)