UploadFile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ching-Lung

    UploadFile

    Hi,

    UploadFile() is always throwing WebException: "The remote
    server returned an error: (405) Method Not Allowed."

    Is there any setting that I miss? IIS setting?

    Please help, thanks!
    -CL
  • Manit Chanthavong

    #2
    Re: UploadFile

    Does your form tag look something like this?

    <FORM id="Form1" method="post" encType="multip art/form-data" runat="server">


    "Ching-Lung" <cltjiong@hotma il.com> wrote in message
    news:023501c3ae dd$a2f6baf0$a50 1280a@phx.gbl.. .[color=blue]
    > Hi,
    >
    > UploadFile() is always throwing WebException: "The remote
    > server returned an error: (405) Method Not Allowed."
    >
    > Is there any setting that I miss? IIS setting?
    >
    > Please help, thanks!
    > -CL[/color]


    Comment

    • Ching-Lung

      #3
      Re: UploadFile

      <FORM id="Form1" method="post" runat="server">

      -CL



      [color=blue]
      >-----Original Message-----
      >Does your form tag look something like this?
      >
      ><FORM id="Form1" method="post" encType="multip art/form-[/color]
      data" runat="server">[color=blue]
      >
      >
      >"Ching-Lung" <cltjiong@hotma il.com> wrote in message
      >news:023501c3a edd$a2f6baf0$a5 01280a@phx.gbl. ..[color=green]
      >> Hi,
      >>
      >> UploadFile() is always throwing WebException: "The[/color][/color]
      remote[color=blue][color=green]
      >> server returned an error: (405) Method Not Allowed."
      >>
      >> Is there any setting that I miss? IIS setting?
      >>
      >> Please help, thanks!
      >> -CL[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Manit Chanthavong

        #4
        Re: UploadFile

        you need to add this:

        encType="multip art/form-data"

        to the form tag.



        Thanks,

        Manit Chanthavong

        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Ching-Lung

          #5
          Re: UploadFile

          Hi,

          I've tried adding encType="multip art/form-data" it doesn't
          throw the 405 web exception but my <input type=file>
          doesn't work. For some reason, <input type=file> is
          an "undefined" object.

          Any idea?
          -CL




          [color=blue]
          >-----Original Message-----
          >Does your form tag look something like this?
          >
          ><FORM id="Form1" method="post" encType="multip art/form-[/color]
          data" runat="server">[color=blue]
          >
          >
          >"Ching-Lung" <cltjiong@hotma il.com> wrote in message
          >news:023501c3a edd$a2f6baf0$a5 01280a@phx.gbl. ..[color=green]
          >> Hi,
          >>
          >> UploadFile() is always throwing WebException: "The[/color][/color]
          remote[color=blue][color=green]
          >> server returned an error: (405) Method Not Allowed."
          >>
          >> Is there any setting that I miss? IIS setting?
          >>
          >> Please help, thanks!
          >> -CL[/color]
          >
          >
          >.
          >[/color]

          Comment

          • Joerg Jooss

            #6
            Re: UploadFile

            "Ching-Lung" wrote:
            [color=blue]
            > Hi,
            >
            > UploadFile() is always throwing WebException: "The remote
            > server returned an error: (405) Method Not Allowed."[/color]

            I guess that is WebClient.Uploa dFile(). Well, if you don't specify the
            HTTP verb, it will post the file. In that case, there must be some web
            application handling the file upload -- which seems not to be case here.

            For a "pure" (no web app) HTTP file upload, try HTTP PUT:

            string url = "http://host/vdir/test.txt";
            WebClient client = new WebClient();
            byte[] response = client.UploadFi le(url, "PUT", @"C:\temp\test. txt");

            This requires write permissions on the virtual directory "vdir".

            Cheers,

            --
            Joerg Jooss
            joerg.jooss@gmx .net

            Comment

            Working...