473,385 Members | 2,004 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,385 software developers and data experts.

HttpPostedFile.SaveAs

Hi,

I am able to use the HttpPostedFile.SaveAs() method to upload and save a
file to the local web machine. However, I would really like to save the
file to a VirtualDirectory.

Does anyone know if this can be done and the syntax to do it?

Thanks

Al
Nov 18 '05 #1
8 8853
Files are not stored in virtual directories. Virtual Directories are part of
the web server configuration, and correspond to file system directories. You
save files to file system directories. If you want to save a file to a
virtual directory, save it to the file system directory which that virtual
directory is mapped to.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Al Smith" <as****@NOSPAMmrisystem.com> wrote in message
news:#x**************@TK2MSFTNGP15.phx.gbl...
Hi,

I am able to use the HttpPostedFile.SaveAs() method to upload and save a
file to the local web machine. However, I would really like to save the
file to a VirtualDirectory.

Does anyone know if this can be done and the syntax to do it?

Thanks

Al

Nov 18 '05 #2
How is security applied then? The aspx user (local machine) then needs
access to a different machine on the network where the VD resides. That is
why I was hoping a VD could be used since access to the VD is associated
with a network user.

Thanks

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eR**************@TK2MSFTNGP11.phx.gbl...
Files are not stored in virtual directories. Virtual Directories are part of the web server configuration, and correspond to file system directories. You save files to file system directories. If you want to save a file to a
virtual directory, save it to the file system directory which that virtual
directory is mapped to.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Al Smith" <as****@NOSPAMmrisystem.com> wrote in message
news:#x**************@TK2MSFTNGP15.phx.gbl...
Hi,

I am able to use the HttpPostedFile.SaveAs() method to upload and save a
file to the local web machine. However, I would really like to save the
file to a VirtualDirectory.

Does anyone know if this can be done and the syntax to do it?

Thanks

Al


Nov 18 '05 #3
You can open the IIS meta-data to find out the physical location of the
virtual directory, then save to that.

--
-Kody
kody at weekendtech dot net
"Custom ASP.Net Web Controls"

"Al Smith" <as****@NOSPAMmrisystem.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I am able to use the HttpPostedFile.SaveAs() method to upload and save a
file to the local web machine. However, I would really like to save the
file to a VirtualDirectory.

Does anyone know if this can be done and the syntax to do it?

Thanks

Al

Nov 18 '05 #4
Virtual Directories, like file system directories, have security, albeit
somewhat different kinds. However, a virtual directory is not associated
with a network user any more than a file system directory is. Each has any
number of authorized users associated with it. However, this is not the
issue. The issue is what account is trying to write the file, and that is
the account under which ASP.Net is running, in both circumstances.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Al Smith" <as****@NOSPAMmrisystem.com> wrote in message
news:#d*************@TK2MSFTNGP10.phx.gbl...
How is security applied then? The aspx user (local machine) then needs
access to a different machine on the network where the VD resides. That is why I was hoping a VD could be used since access to the VD is associated
with a network user.

Thanks

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eR**************@TK2MSFTNGP11.phx.gbl...
Files are not stored in virtual directories. Virtual Directories are part
of
the web server configuration, and correspond to file system directories.

You
save files to file system directories. If you want to save a file to a
virtual directory, save it to the file system directory which that

virtual directory is mapped to.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Al Smith" <as****@NOSPAMmrisystem.com> wrote in message
news:#x**************@TK2MSFTNGP15.phx.gbl...
Hi,

I am able to use the HttpPostedFile.SaveAs() method to upload and save a file to the local web machine. However, I would really like to save the file to a VirtualDirectory.

Does anyone know if this can be done and the syntax to do it?

Thanks

Al



Nov 18 '05 #5
Thanks for the feedback Cody. The problem has been access to a network
machine from the anonymous access account. Thus I was hoping the
VirtualDirectory could somehow be used in reverse so to say (using the user
associated with it) which is not the case. So finding the physical location
is not really the issue, accessing it anonymously is.

Since we have components running as a network user, we used them to provide
the functionality needed.

Thanks
"Kody Brown" <ko**@noway.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
You can open the IIS meta-data to find out the physical location of the
virtual directory, then save to that.

--
-Kody
kody at weekendtech dot net
"Custom ASP.Net Web Controls"

"Al Smith" <as****@NOSPAMmrisystem.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I am able to use the HttpPostedFile.SaveAs() method to upload and save a
file to the local web machine. However, I would really like to save the
file to a VirtualDirectory.

Does anyone know if this can be done and the syntax to do it?

Thanks

Al


Nov 18 '05 #6
Hi Al,

Yes, the critical problem is that when accessing a remote shared folder( or
event a local folder), the asp.net application may haven't sufficient
permission. And generally anonymous access is not suitable since that
require the folder be configured as everyone accessable. I think one means
is to grant the folder's required permissions to a certain account(Domain
account or a duplicated local account which has identical username and
password on two machines), then we need to impersonate the asp.net context
when we need to do file operations in the folder. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #7
Thanks Steven for the ideas, security is important.

Al
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Cj**************@cpmsftngxa10.phx.gbl...
Hi Al,

Yes, the critical problem is that when accessing a remote shared folder( or event a local folder), the asp.net application may haven't sufficient
permission. And generally anonymous access is not suitable since that
require the folder be configured as everyone accessable. I think one means
is to grant the folder's required permissions to a certain account(Domain
account or a duplicated local account which has identical username and
password on two machines), then we need to impersonate the asp.net context
when we need to do file operations in the folder. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #8
Thanks Al,

I'm glad that my suggestions is of assistance.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #9

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

Similar topics

1
by: Jeff | last post by:
I am using the HttpPostedFile to allow users to upload files to a server farm. The SaveAs() saves to a shared network path (\\SERVER\SHARE) so that no matter which web server is taking the...
4
by: | last post by:
Hi! It seems the HttpPostedFile object can't save a file to a destination withing the web's structure. I want to upload pictures from a page and store them in a subfolder to the web folder...
1
by: terrorix | last post by:
I want to save uploaded file to disk. I have this construction: HttpPostedFile myFile = ((HttpRequest)Request).Files; if (myFile != null) { string fn =...
2
by: Michael Huhn | last post by:
I have a WebForm with several File-Inputs. On the server side I loop through the Request.PostedFiles and call a .SaveAs to a specific subfolder of my web. I get a System.UnauthorizedAccessException...
0
by: Eli Heifetz | last post by:
Hi, I'm uploading files with multipart/form-data and saving them to UNC share using impersonation. Weird thing happens when I step into with a debugger: If I enclose myfile.SaveAs() with...
5
by: MSDN | last post by:
Does anyone know why I am getting Invalid cast exception??? For Each oFile As System.web.HttpPostedFile In Request.Files ....... etc..... Next I Checked that
2
by: binujose | last post by:
I am trying to access a folder which resides outside the application.My application hosted in a medium trust level server. I am getting error in the below line of code. ...
1
by: Ralph Watermann | last post by:
Hi, we upload an Excel-file via a FileUpload-Control into an HttpPostedFile object. Now we want to access the contained data directly without saving it to a temp file. Is this possible? So...
4
by: macap.usenet | last post by:
Hello, I´ve a strange problem with my HttpPostedFile object. I coded a File Upload where the user can upload a zip file. My code looks like this: HttpFileCollection files =...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.