473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

File Upload. Root Path.

Hello,

I am uploading a file as follows:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

If FileUpload1.HasFile Then
FileUpload1.SaveAs("~\Temporary\" + FileUpload1.FileName)
Label2.Text = "File Uploaded: " + FileUpload1.FileName
Else
Label2.Text = "No File Uploaded."
End If

I get the following error:

The SaveAs method is configured to require a rooted path, and the path
'~\App_Temporary\Red Ceiling Lamp 04 [By27] [Free].jpg' is not rooted.

I know this means I should have SaveAs("C:\...")

But I also know that Temporary is in the same folder then the Aspx
file that has the FileUpload.

Can't I get that root?

Thanks,

Miguel
Feb 12 '08 #1
2 22030
Try
FileUpload1.SaveAs(Server.MapPath("~\Temporary\" + FileUpload1.FileName))

George.

"shapper" <md*****@gmail.comwrote in message
news:de**********************************@i72g2000 hsd.googlegroups.com...
Hello,

I am uploading a file as follows:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

If FileUpload1.HasFile Then
FileUpload1.SaveAs("~\Temporary\" + FileUpload1.FileName)
Label2.Text = "File Uploaded: " + FileUpload1.FileName
Else
Label2.Text = "No File Uploaded."
End If

I get the following error:

The SaveAs method is configured to require a rooted path, and the path
'~\App_Temporary\Red Ceiling Lamp 04 [By27] [Free].jpg' is not rooted.

I know this means I should have SaveAs("C:\...")

But I also know that Temporary is in the same folder then the Aspx
file that has the FileUpload.

Can't I get that root?

Thanks,

Miguel

Feb 12 '08 #2
On Feb 12, 1:09 pm, "George Ter-Saakov" <gt-...@cardone.comwrote:
Try
FileUpload1.SaveAs(Server.MapPath("~\Temporary\" + FileUpload1.FileName))

George.

"shapper" <mdmo...@gmail.comwrote in message

news:de**********************************@i72g2000 hsd.googlegroups.com...
Hello,
I am uploading a file as follows:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
If FileUpload1.HasFile Then
FileUpload1.SaveAs("~\Temporary\" + FileUpload1.FileName)
Label2.Text = "File Uploaded: " + FileUpload1.FileName
Else
Label2.Text = "No File Uploaded."
End If
I get the following error:
The SaveAs method is configured to require a rooted path, and the path
'~\App_Temporary\Red Ceiling Lamp 04 [By27] [Free].jpg' is not rooted.
I know this means I should have SaveAs("C:\...")
But I also know that Temporary is in the same folder then the Aspx
file that has the FileUpload.
Can't I get that root?
Thanks,
Miguel
Thanks,

It worked.

Miguel
Feb 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
1
by: BW | last post by:
I am creating an upload/download function for an extranet site. Files will be uploaded to directory based upon the users login and associated project. The function works as long as I use "c:\Temp"...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
2
by: Barkster | last post by:
I'm trying to move some files on my server but I cannot get the path right. I've messed with this and can't get it right. Is there a way to debug the path of a file on the server? Here is what...
17
by: Paul | last post by:
On my development computer, I have virtual named host set up, like www.site1.lab. When I upload those to my web site for customer review under mywebsite.com/clients/site1/ it throws some of the...
6
by: fiefie.niles | last post by:
In ASP.Net (VS 2005), is there a way to limit the user to upload a file up to certain size (say, I would like to limit the user to upload at the maximum 1 meg of file) ? Thank you
16
by: Lawrence Krubner | last post by:
To guard against our users possibly uploading huge files, I've got this in my php.ini file: ; Maximum size of POST data that PHP will accept. post_max_size = 10M On a server running Ubuntu...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
7
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.