Re: FileUpload
Efran Cobisi <[email protected]> Tue, 4 Sep 2007 14:10:32 +0200
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Organization | cobisi.com |
| Message-ID | <[email protected]> |
[I've just answered the same question in the Advanced .NET list but I'm
replying here too for readers convenience.]
Hi Lior,
Please avoid cross posting...
To save the content of your uploaded file you could simply bypass the
checks performed by the SaveAs() method and manually persist its data.
Here's a short code fragment (C#):
using (FileStream stream = new
FileStream("\\computerName\sharedPath\test.bin", FileMode.Create))
FileUpload1.InputStream.WriteTo(stream);
Also pay attention to the fact that volume shares (C$, D$, etc) are by
default visibile to administrators only, if I recall correctly.
Hope this helps.
--
Efran Cobisi
http://www.cobisi.com
Lior Levy wrote:
> Chris, thank you for the answer.
> So what do you suggest?
> How can I upload a file from a web server & save it on another server?
>
> Lior.
>
>
> -----Original Message-----
> From: Discussion of building .NET applications targeted for the Web [mailto:[email protected]] On Behalf Of Chris Anderson
> Sent: Tuesday, September 04, 2007 1:36 AM
> To: [email protected]
> Subject: Re: [DOTNET-WEB] FileUpload
>
> How are you mapping the drive?
> If you are mapping it from your personal account, other users (for example, the ASPNET user that the web server is using) do not see the mapping
>
>
> -----Original Message-----
> From: "Lior Levy"<[email protected]>
> Sent: 03/09/07 18:16:10
> To: "[email protected]"<[email protected]>
> Subject: [DOTNET-WEB] FileUpload
>
> Hello,
>
>
>
> I am trying to Upload & save a file in the web server, When I specify a physical path like:
>
> FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))
>
> It works fine.
>
>
>
> But when I map the drive & use something like this:
>
> FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))
>
>
>
> I get the error:
>
> Could not find a part of the path F:\foldername\globalsProc.doc'.
>
> Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldern
>
>
>
> [Message truncated. Tap Edit->Mark for Download to get remaining portion.]
>
> -----Unmodified Original Message-----
> Hello,
>
>
>
> I am trying to Upload & save a file in the web server, When I specify a physical path like:
>
> FileUpload1.SaveAs("C:\Files\" & FileUpload1.FileName))
>
> It works fine.
>
>
>
> But when I map the drive & use something like this:
>
> FileUpload1.SaveAs("F:\foldername\" & FileUpload1.FileName))
>
>
>
> I get the error:
>
> Could not find a part of the path F:\foldername\globalsProc.doc'.
>
> Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'F:\foldername\globalsProc.doc'.
>
>
>
> If I use this:
>
> FileUpload1.SaveAs("\\comuterName\D$\foldername\" & FileUpload1.FileName))
>
>
>
> I get the error:
>
> The SaveAs method is configured to require a rooted path, and the path '\\comuterName\d$\foldername\globalsProc.doc'' is not rooted.
>
>
>
> I have Full NTFS control for the user on the drive.
>
>
>
>
>
> Any idea?
>
> Thanks in advance,
>
> Lior.
>
>
>
>
>
>
>
>
>
>
> ===================================
> This list is hosted by DevelopMentorֲ® http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentorֲ® http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>
===================================
This list is hosted by DevelopMentorֲ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com