?
Solved

Upload File from Client to server

Posted on 2009-02-16
6
Medium Priority
?
959 Views
Last Modified: 2012-05-06
I have an asp.net web application. In this section I have an UploadFile and Button to upload a file from a client PC to a Web Server. This works on localhost where the server and client are the same, but I need for this to work on the production server with a PC connecting from the internet.

 
<input ID="UploadFile" runat="server" name="UploadFile" type="file" />
 
<asp:imagebutton id="bttnUpload" runat="server" ImageUrl="~/_images/Upload.jpg"></asp:imagebutton>
 
 
 
Protected Sub bttnUpload_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles bttnUpload.Click
   
 
                Dim myFile As New FileInfo(UploadFile.Value)
 
                'Set server location where file will be uploaded to.
                Dim pathToCopy = Server.MapPath("~/Files/Docs/CRM/" & Session("CompCode") & "/Leads/")
                
    'Check whether location has been created. Manually set write permissions to the directory.
                If Not Exists(pathToCopy) Then
                    CreateDirectory(pathToCopy)
                End If
 
                'Copy file from client to the server?
                If myFile.Exists = True Then
                    myFile.CopyTo(pathToCopy & myFile.Name, True)
                Else
                	'Message file not found  exit.
                End If
 
 
End Sub
 
ERROR

Open in new window

0
Comment
Question by:JenebyM
  • 3
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
Daniel Junges earned 900 total points
ID: 23647936
Please see:
"How to upload a file to a Web server in ASP.NET by using Visual Basic .NET"
http://support.microsoft.com/kb/323245
0
 

Author Comment

by:JenebyM
ID: 23648403
Junges

I am not sure whether you actually looked at my code.! I have looked at the link and spent the last 45 mins replicating that info.

Apart from minor syntax changes there is not much that is fundamentally different.

The problem I have shown at the end of my code as the error also appears on this one.

I have looked at a number of links on this issue so it would be useful to get someone to actually look at the code provided rather than just sending another link. I am sure an experts review of my code will actually reveal what is missing. A link that supports an actual answer is of course useful.

 
0
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23649861
I don't see any Error in the posted code except for the text ERROR.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:JenebyM
ID: 23650003
ERROR
File Doc6.txt not found at specified location. i.e C:\WINDOWS\system32

The file's physical location on the client pc is C:\Temp\Doc6.txt

This exception message shows that uploadFile is looking for Doc6.txt in a different location i.e C:\WINDOWS\system32

Does this help?
0
 
LVL 12

Assisted Solution

by:CB_Thirumalai
CB_Thirumalai earned 600 total points
ID: 23650790
I guess you are doing the file upload differently.  Please refer the link provided by junges.  It tells the way how the file should be copied to the desired location.  You may need to reframe the statements and use PostedFile property.
0
 

Author Closing Comment

by:JenebyM
ID: 31547240
I have used the link provided by Junges and reframed all the statements as suggested by CB and this now works as desired.

Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question