Link to home
Start Free TrialLog in
Avatar of SimonPrice33
SimonPrice33

asked on

ASP.NET file upload

HI Experts

I am having some issues with file uploads.

In a local test environment it works perfectly and saves the file in the directory i need it to, however on the web server no such luck.

the code is

 Dim serverfilename As String = Path.GetFileName(uploader.PostedFile.FileName)
            'file upload - added 20/09/2012
            Dim uploaddirectory As String = Path.Combine(Request.PhysicalApplicationPath, "files\")
            'Dim fullfilepath As String = Path.Combine(uploaddirectory, serverfilename)
            Dim fullfilepath As String = Path.Combine(uploaddirectory, serverfilename)
            Try
                uploader.PostedFile.SaveAs(fullfilepath)

            Catch ex As Exception
                Response.Write("Ooopps Something went wrong!")
            End Try

            Session("Fileupload") = Path.GetFileName(uploader.PostedFile.FileName)
            Response.Redirect("ChangeEntered.aspx")

        Catch ex As Exception

Open in new window


now, thinking that i had this wrong i also looked at this which game me the correct path on the web server. which also may in turn be wrong as its giving

C:\Inetpub\wwwroot\ChangeControl\files\thefilename

 Dim uploaddirectory As String = Path.Combine(Request.PhysicalApplicationPath, "files\")
        'Label1.Text = uploaddirectory
        Dim serverfilename As String = "thefilename"
        Dim fullfilepath As String = Path.Combine(uploaddirectory, serverfilename)
        Label1.Text = fullfilepath

Open in new window


the phycial server name is simonwebserver1

and would be grateful for any and all help possible.

thanks

Simon
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of OriNetworks
OriNetworks

Check permissions on the files/ folder to make sure the application pool identity has write access. Otherwise, change the catch statement to  Response.Write("Ooopps Something went wrong!" & ex.Message) so you can view the actual error message.
Avatar of SimonPrice33

ASKER

i had checked in IIS, but i didnt consider the NTFS permissions.

this has now been set to full controll.

thanks

SImon
What was puzzling.. is it didnt upload the file but didnt give me the error either...

but all sorted now.  :)