uploading a file from the user's PC to my server using vb.net












0















I created a simple .Net 4.6 site with an asp:FileUpload and asp:Button control so that users can browse their PC for a file, and then upload it to my server.



I've gotten the first part down as you can see below. However, I don't know how to get the user's file to my server. It's just a Windows Server 2012 with IIS installed.



Here is what I have so far:



<asp:FileUpload CssClass="upload" ID="flImageFromComputer" runat="server" />

<asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="btn" />

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click

Try
If Me.flImageFromComputer.HasFile Then
With Me.flImageFromComputer
' *** not sure how to get it to the server ***
End With
End If

Catch ex As Exception
Response.Write(ex.ToString)
End Try


I've tried Googling, but can't really find anything on how to transfer the file to my server.



Any help would be great! :)



Thanks!










share|improve this question



























    0















    I created a simple .Net 4.6 site with an asp:FileUpload and asp:Button control so that users can browse their PC for a file, and then upload it to my server.



    I've gotten the first part down as you can see below. However, I don't know how to get the user's file to my server. It's just a Windows Server 2012 with IIS installed.



    Here is what I have so far:



    <asp:FileUpload CssClass="upload" ID="flImageFromComputer" runat="server" />

    <asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="btn" />

    Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click

    Try
    If Me.flImageFromComputer.HasFile Then
    With Me.flImageFromComputer
    ' *** not sure how to get it to the server ***
    End With
    End If

    Catch ex As Exception
    Response.Write(ex.ToString)
    End Try


    I've tried Googling, but can't really find anything on how to transfer the file to my server.



    Any help would be great! :)



    Thanks!










    share|improve this question

























      0












      0








      0








      I created a simple .Net 4.6 site with an asp:FileUpload and asp:Button control so that users can browse their PC for a file, and then upload it to my server.



      I've gotten the first part down as you can see below. However, I don't know how to get the user's file to my server. It's just a Windows Server 2012 with IIS installed.



      Here is what I have so far:



      <asp:FileUpload CssClass="upload" ID="flImageFromComputer" runat="server" />

      <asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="btn" />

      Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click

      Try
      If Me.flImageFromComputer.HasFile Then
      With Me.flImageFromComputer
      ' *** not sure how to get it to the server ***
      End With
      End If

      Catch ex As Exception
      Response.Write(ex.ToString)
      End Try


      I've tried Googling, but can't really find anything on how to transfer the file to my server.



      Any help would be great! :)



      Thanks!










      share|improve this question














      I created a simple .Net 4.6 site with an asp:FileUpload and asp:Button control so that users can browse their PC for a file, and then upload it to my server.



      I've gotten the first part down as you can see below. However, I don't know how to get the user's file to my server. It's just a Windows Server 2012 with IIS installed.



      Here is what I have so far:



      <asp:FileUpload CssClass="upload" ID="flImageFromComputer" runat="server" />

      <asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="btn" />

      Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click

      Try
      If Me.flImageFromComputer.HasFile Then
      With Me.flImageFromComputer
      ' *** not sure how to get it to the server ***
      End With
      End If

      Catch ex As Exception
      Response.Write(ex.ToString)
      End Try


      I've tried Googling, but can't really find anything on how to transfer the file to my server.



      Any help would be great! :)



      Thanks!







      vb.net .net-4.0






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 16:29









      SkyeBoniwellSkyeBoniwell

      2,17074488




      2,17074488
























          1 Answer
          1






          active

          oldest

          votes


















          2














          Instead of doing a google search, I suggest you look at the documentation. You would see that it contains a SaveAs method. It should do what you are looking for.



          Me.flImageFromComputer.SaveAs("c:...file.ext")


          You'll have to make sure the running user has access to the path.






          share|improve this answer
























          • Thanks! I actually did see that, but assumed it was used to save to the users PC and not my server.

            – SkyeBoniwell
            Nov 21 '18 at 16:38






          • 2





            @SkyeBoniwell ah! well, the vb part is run on the server. Read up on the difference between client side and server side code. It can be confusing with web app.

            – the_lotus
            Nov 21 '18 at 16:46











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416535%2fuploading-a-file-from-the-users-pc-to-my-server-using-vb-net%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Instead of doing a google search, I suggest you look at the documentation. You would see that it contains a SaveAs method. It should do what you are looking for.



          Me.flImageFromComputer.SaveAs("c:...file.ext")


          You'll have to make sure the running user has access to the path.






          share|improve this answer
























          • Thanks! I actually did see that, but assumed it was used to save to the users PC and not my server.

            – SkyeBoniwell
            Nov 21 '18 at 16:38






          • 2





            @SkyeBoniwell ah! well, the vb part is run on the server. Read up on the difference between client side and server side code. It can be confusing with web app.

            – the_lotus
            Nov 21 '18 at 16:46
















          2














          Instead of doing a google search, I suggest you look at the documentation. You would see that it contains a SaveAs method. It should do what you are looking for.



          Me.flImageFromComputer.SaveAs("c:...file.ext")


          You'll have to make sure the running user has access to the path.






          share|improve this answer
























          • Thanks! I actually did see that, but assumed it was used to save to the users PC and not my server.

            – SkyeBoniwell
            Nov 21 '18 at 16:38






          • 2





            @SkyeBoniwell ah! well, the vb part is run on the server. Read up on the difference between client side and server side code. It can be confusing with web app.

            – the_lotus
            Nov 21 '18 at 16:46














          2












          2








          2







          Instead of doing a google search, I suggest you look at the documentation. You would see that it contains a SaveAs method. It should do what you are looking for.



          Me.flImageFromComputer.SaveAs("c:...file.ext")


          You'll have to make sure the running user has access to the path.






          share|improve this answer













          Instead of doing a google search, I suggest you look at the documentation. You would see that it contains a SaveAs method. It should do what you are looking for.



          Me.flImageFromComputer.SaveAs("c:...file.ext")


          You'll have to make sure the running user has access to the path.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 16:35









          the_lotusthe_lotus

          10.1k12246




          10.1k12246













          • Thanks! I actually did see that, but assumed it was used to save to the users PC and not my server.

            – SkyeBoniwell
            Nov 21 '18 at 16:38






          • 2





            @SkyeBoniwell ah! well, the vb part is run on the server. Read up on the difference between client side and server side code. It can be confusing with web app.

            – the_lotus
            Nov 21 '18 at 16:46



















          • Thanks! I actually did see that, but assumed it was used to save to the users PC and not my server.

            – SkyeBoniwell
            Nov 21 '18 at 16:38






          • 2





            @SkyeBoniwell ah! well, the vb part is run on the server. Read up on the difference between client side and server side code. It can be confusing with web app.

            – the_lotus
            Nov 21 '18 at 16:46

















          Thanks! I actually did see that, but assumed it was used to save to the users PC and not my server.

          – SkyeBoniwell
          Nov 21 '18 at 16:38





          Thanks! I actually did see that, but assumed it was used to save to the users PC and not my server.

          – SkyeBoniwell
          Nov 21 '18 at 16:38




          2




          2





          @SkyeBoniwell ah! well, the vb part is run on the server. Read up on the difference between client side and server side code. It can be confusing with web app.

          – the_lotus
          Nov 21 '18 at 16:46





          @SkyeBoniwell ah! well, the vb part is run on the server. Read up on the difference between client side and server side code. It can be confusing with web app.

          – the_lotus
          Nov 21 '18 at 16:46


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416535%2fuploading-a-file-from-the-users-pc-to-my-server-using-vb-net%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy