Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2007, 09:42 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default FileUpload "Rooted" error

I am trying to create a simple FileUpload control to allow a user to upload pictures to a "pictures" folder. I have to admit, I have very little experience with creating sites, and how this would work in production. I tried the below function and get the following error:

The SaveAs method is configured to require a rooted path, and the path '~/Pictures/memberback.jpg' is not rooted.

1) What am I doing wrong?
2) Is it your experience that, if I host this with a company (such as GoDaddy) do these companies usually allow for you to upload this way to a directory?

Thanks, in advance,
Rob




 Protected Sub uploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadButton.Click
        If FileUpload1.HasFile Then
            Try
                FileUpload1.SaveAs("~/Pictures/" & FileUpload1.FileName)
            Catch ex As Exception
                FileUploadReport.Text = "Failed because: <br/>" & ex.Message
            End Try
        Else
            FileUploadReport.Text = "Please select a file before clicking the Upload Button"
        End If
    End Sub

 
Old February 3rd, 2007, 07:32 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I imagine the problem is that the SaveAs() method doesn't automatically resolve the URL you provide (because it's not a web related class). You need to pass in a resolved URL, something like this:

FileUpload1.SaveAs(Server.MapPath("~/Pictures/") & FileUpload1.FileName)

-Peter
 
Old July 4th, 2007, 01:52 AM
Authorized User
 
Join Date: Dec 2004
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

Hey Peter,

If the folder is inside the application path, this method will work but if I'm having my storage server seperately and mapping the store folder into the application server how could I map the path in this way. I tried to store directly to the storage folder by using the url but it is throwing the same exception. Help out for the url path upload...

Thanks and Regards,

Senthil Kumar M.
 
Old July 4th, 2007, 09:05 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you are saving to a known location outside of the web application then you can't map from the application path and don't need to. Just provide the proper full path to the destination.

Be sure not to confuse the term "map" this is context with the mapping of a drive in windows. The two are different. Are you referring to the former or the latter?

-Peter
 
Old July 20th, 2007, 01:17 AM
Authorized User
 
Join Date: Dec 2004
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

Nopes, I'm not using the map path but I'm using the direct path in an UNC path. I followed all the steps to store into an UNC path. At first, I got the authentication errors so I used the credentials for the folder as well as for the application. But even after this I faced the problem that it is saying that it is not a rooted path. So I used the drive mapping but that also failed... This time I got the error that path not found or failed authentication...

Thanks and Regards,

Senthil Kumar M.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access denied error when using FileUpload Control mii2029 ASP.NET 3.5 Basics 0 October 25th, 2008 05:45 PM
Fileupload in Ajax bobwith5 ASP.NET 2.0 Professional 3 October 18th, 2008 09:59 AM
FileUpload control aliirfan84 ASP.NET 2.0 Professional 1 June 2nd, 2007 03:37 PM
FileUpload FIlter tony_j_hug ASP.NET 2.0 Basics 1 October 28th, 2005 06:55 PM
URGENT : Jakarta Commons FileUpload error sherbir Servlets 1 August 5th, 2004 06:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.