uploading a file from the user's PC to my server using vb.net
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
add a comment |
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
add a comment |
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
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
vb.net .net-4.0
asked Nov 21 '18 at 16:29
SkyeBoniwellSkyeBoniwell
2,17074488
2,17074488
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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