WebClient Upload

Discussion in 'ASP .Net' started by =?Utf-8?B?dmFzaW1v?=, Sep 24, 2007.

  1. Have the following code:
    wkLocalPath = "C:\A\1.jpg"
    wkServerPath = "http://servername/dirname/1.jpg"
    wcClient.Credentials = New NetworkCredential("UID", "PW")
    wcClient.UploadFile(wkServerPath, "PUT", wkLocalPath)

    File exists on C.
    Dir exist on server (ASPNET user and Admin user have full rights) (tried both)
    Created virtual for Dirname and gave it write access in properties)
    "POST" gives same results.

    with or without credentials, throws: (404) Not Found
    It looks like a security permissions thing. Just can't figure out what.
    Someone thought it was a bug in Webclient since 1.0

    Webclient download works fine.
    Don't have a web page to put a file or Upload control on. Need to pull data
    from client machine on the fly through inline code. Trying to create a DLL as
    a service mod to do upload/Download from server.

    Any help would be appreciated.
     
    =?Utf-8?B?dmFzaW1v?=, Sep 24, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?dmFzaW1v?=

    bruce barker Guest

    the serverpath needs to be a url that supports a fileupload post, not
    where to write the file. the error is because an image does not suppport
    a post.

    if you want to access a webserver as a filesystem, look at webdav.

    -- bruce (sqlwork.com)

    vasimo wrote:
    > Have the following code:
    > wkLocalPath = "C:\A\1.jpg"
    > wkServerPath = "http://servername/dirname/1.jpg"
    > wcClient.Credentials = New NetworkCredential("UID", "PW")
    > wcClient.UploadFile(wkServerPath, "PUT", wkLocalPath)
    >
    > File exists on C.
    > Dir exist on server (ASPNET user and Admin user have full rights) (tried both)
    > Created virtual for Dirname and gave it write access in properties)
    > "POST" gives same results.
    >
    > with or without credentials, throws: (404) Not Found
    > It looks like a security permissions thing. Just can't figure out what.
    > Someone thought it was a bug in Webclient since 1.0
    >
    > Webclient download works fine.
    > Don't have a web page to put a file or Upload control on. Need to pull data
    > from client machine on the fly through inline code. Trying to create a DLL as
    > a service mod to do upload/Download from server.
    >
    > Any help would be appreciated.
    >
    >
    >
     
    bruce barker, Sep 24, 2007
    #2
    1. Advertising

  3. Thanks for your reply.
    I'm a little confused (as always).
    What do you mean by "the serverpath needs to be a url that supports a
    fileupload post, not where to write the file"? Everything I read indicates
    that the file name to create is appended to the back of the URL. I created a
    virtual dir for the physical path and gave it write access.
    I tried a POST as a last resort. I was under the impression that the POST is
    for text data only. I am using a PUT which I thought handled all data streams.
    I thought the 404(not found) was actually a security error not an
    operational problem. Do you think I wrong in that assumption?
    Thanks Vic


    "bruce barker" wrote:

    > the serverpath needs to be a url that supports a fileupload post, not
    > where to write the file. the error is because an image does not suppport
    > a post.
    >
    > if you want to access a webserver as a filesystem, look at webdav.
    >
    > -- bruce (sqlwork.com)
    >
    > vasimo wrote:
    > > Have the following code:
    > > wkLocalPath = "C:\A\1.jpg"
    > > wkServerPath = "http://servername/dirname/1.jpg"
    > > wcClient.Credentials = New NetworkCredential("UID", "PW")
    > > wcClient.UploadFile(wkServerPath, "PUT", wkLocalPath)
    > >
    > > File exists on C.
    > > Dir exist on server (ASPNET user and Admin user have full rights) (tried both)
    > > Created virtual for Dirname and gave it write access in properties)
    > > "POST" gives same results.
    > >
    > > with or without credentials, throws: (404) Not Found
    > > It looks like a security permissions thing. Just can't figure out what.
    > > Someone thought it was a bug in Webclient since 1.0
    > >
    > > Webclient download works fine.
    > > Don't have a web page to put a file or Upload control on. Need to pull data
    > > from client machine on the fly through inline code. Trying to create a DLL as
    > > a service mod to do upload/Download from server.
    > >
    > > Any help would be appreciated.
    > >
    > >
    > >

    >
     
    =?Utf-8?B?dmFzaW1v?=, Sep 25, 2007
    #3
  4. The method PUT must be supported on a server. So server in response to
    method PUT need to get the file and save it to proper folder.

    By default (if you did nit do anything special) IIS does not support method
    PUT. At least I believe so.

    but you will have much better chances of getting it to work if you create
    your onw uploadfile.aspx that accempt uploaded file

    sample from MSDN:

    MyUpload.aspx
    <%@ Import Namespace="System"%>
    <%@ Import Namespace="System.IO"%>
    <%@ Import Namespace="System.Net"%>
    <%@ Import NameSpace="System.Web"%>

    <Script language="C#" runat=server>
    void Page_Load(object sender, EventArgs e) {

    foreach(string f in Request.Files.AllKeys) {
    HttpPostedFile file = Request.Files[f];
    file.SaveAs("c:\\inetpub\\test\\UploadedFiles\\" + file.FileName);
    }
    }

    Code to upload file
    myWebClient.UploadFile("http://myserver/MyUpload.aspx", "POST",
    "filename.jpg");


    George.

    "vasimo" <> wrote in message
    news:...
    > Have the following code:
    > wkLocalPath = "C:\A\1.jpg"
    > wkServerPath = "http://servername/dirname/1.jpg"
    > wcClient.Credentials = New NetworkCredential("UID", "PW")
    > wcClient.UploadFile(wkServerPath, "PUT", wkLocalPath)
    >
    > File exists on C.
    > Dir exist on server (ASPNET user and Admin user have full rights) (tried
    > both)
    > Created virtual for Dirname and gave it write access in properties)
    > "POST" gives same results.
    >
    > with or without credentials, throws: (404) Not Found
    > It looks like a security permissions thing. Just can't figure out what.
    > Someone thought it was a bug in Webclient since 1.0
    >
    > Webclient download works fine.
    > Don't have a web page to put a file or Upload control on. Need to pull
    > data
    > from client machine on the fly through inline code. Trying to create a DLL
    > as
    > a service mod to do upload/Download from server.
    >
    > Any help would be appreciated.
    >
    >
    >
     
    George Ter-Saakov, Sep 25, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grant Harmeyer

    WebClient Class / Upload File / IIS 405 Error

    Grant Harmeyer, Sep 7, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    4,606
    Sayed Hashimi
    Sep 8, 2004
  2. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,581
    Bruce Barker
    Aug 3, 2005
  3. Phillip N Rounds

    File Upload issues with WebClient.UploadFile

    Phillip N Rounds, Feb 2, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    11,410
    Bruce Barker
    Feb 2, 2006
  4. Fabrice

    Webclient.upload + ftp + user select

    Fabrice, Jun 27, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    295
    Fabrice
    Jun 27, 2009
  5. Stacey

    response from webclient.upload

    Stacey, Apr 12, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    141
    Stacey
    Apr 12, 2006
Loading...

Share This Page