Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Upload if files from client PC or local network

Reply
Thread Tools

Upload if files from client PC or local network

 
 
=?Utf-8?B?U2lvYmhhbg==?=
Guest
Posts: n/a
 
      11-01-2005
Hi - I create a input box as follows:
<INPUT id="inpJobDescEmpSpec" style="BORDER-RIGHT: gray thin solid;
BORDER-TOP: gray thin solid; Z-INDEX: 181; LEFT: 232px; BORDER-LEFT: gray
thin solid; WIDTH: 640px; BORDER-BOTTOM: gray thin solid; POSITION: absolute;
TOP: 400px; HEIGHT: 22px" tabIndex="27" type="file" maxLength="250" size="87"
name="inpJobDescEmpSpec" RunAt="Server">

to allow the user to select a file which I want saved to a SQL Server
database.

On the save I then run this code to insert the document into the database:

'only try and attach file if there is one specified
Dim impersonationContext As
System.Security.Principal.WindowsImpersonationCont ext
Dim currentWindowsIdentity As
System.Security.Principal.WindowsIdentity

currentWindowsIdentity = CType(User.Identity,
System.Security.Principal.WindowsIdentity)
impersonationContext = currentWindowsIdentity.Impersonate()

'Insert your code that runs under the security context of
the authenticating user here.
If Len(Trim(inpJobDescEmpSpec.Value)) <> 0 Then
Dim fs As New System.IO.FileStream _
(inpJobDescEmpSpec.Value,
System.IO.FileMode.OpenOrCreate, _
System.IO.FileAccess.Read)
Dim MyData(fs.Length) As Byte
fs.Read(MyData, 0, fs.Length)
fs.Close()
.JobDescEmpSpecDoc = MyData
.UpdateDocument = True
Else
Dim MyData(0) As Byte
.JobDescEmpSpecDoc = MyData
.UpdateDocument = False
End If
impersonationContext.Undo()

(where I am setting MyData to a byte property of my data class)

This works perfectly fine in the development environment (my PC has Visual
Studio and is the web server connectin to a SQL server database on out
network.

I can browse for and attach files with or network paths (C:\Folder\File.doc
or \\Server\Share\Folder\File.doc)

If I connect to the website on my PC from another PC the local drive upload
works fine (C:\Folder\File.doc) but the network upload fails because
somewhere along the way the backslashes are beibng removed so it is trying to
access file \ServerShareFolderFile.doc

Anyone any idea why this is?

Thanks in advance
Siobhan

 
Reply With Quote
 
 
 
 
intrader
Guest
Posts: n/a
 
      11-01-2005
On Tue, 01 Nov 2005 06:57:03 -0800, Siobhan wrote:

> Hi - I create a input box as follows:
> <INPUT id="inpJobDescEmpSpec" style="BORDER-RIGHT: gray thin solid;
> BORDER-TOP: gray thin solid; Z-INDEX: 181; LEFT: 232px; BORDER-LEFT: gray
> thin solid; WIDTH: 640px; BORDER-BOTTOM: gray thin solid; POSITION: absolute;
> TOP: 400px; HEIGHT: 22px" tabIndex="27" type="file" maxLength="250" size="87"
> name="inpJobDescEmpSpec" RunAt="Server">
>
> to allow the user to select a file which I want saved to a SQL Server
> database.
>
> On the save I then run this code to insert the document into the database:
>
> 'only try and attach file if there is one specified
> Dim impersonationContext As
> System.Security.Principal.WindowsImpersonationCont ext
> Dim currentWindowsIdentity As
> System.Security.Principal.WindowsIdentity
>
> currentWindowsIdentity = CType(User.Identity,
> System.Security.Principal.WindowsIdentity)
> impersonationContext = currentWindowsIdentity.Impersonate()
>
> 'Insert your code that runs under the security context of
> the authenticating user here.
> If Len(Trim(inpJobDescEmpSpec.Value)) <> 0 Then
> Dim fs As New System.IO.FileStream _
> (inpJobDescEmpSpec.Value,
> System.IO.FileMode.OpenOrCreate, _
> System.IO.FileAccess.Read)
> Dim MyData(fs.Length) As Byte
> fs.Read(MyData, 0, fs.Length)
> fs.Close()
> .JobDescEmpSpecDoc = MyData
> .UpdateDocument = True
> Else
> Dim MyData(0) As Byte
> .JobDescEmpSpecDoc = MyData
> .UpdateDocument = False
> End If
> impersonationContext.Undo()
>
> (where I am setting MyData to a byte property of my data class)
>
> This works perfectly fine in the development environment (my PC has Visual
> Studio and is the web server connectin to a SQL server database on out
> network.
>
> I can browse for and attach files with or network paths (C:\Folder\File.doc
> or \\Server\Share\Folder\File.doc)
>
> If I connect to the website on my PC from another PC the local drive upload
> works fine (C:\Folder\File.doc) but the network upload fails because
> somewhere along the way the backslashes are beibng removed so it is trying to
> access file \ServerShareFolderFile.doc
>
> Anyone any idea why this is?
>
> Thanks in advance
> Siobhan

The problem is that inside strings, the backslash is considered an escape
to allow special characters. So you may use double slashes.

 
Reply With Quote
 
 
 
 
Bruce Barker
Guest
Posts: n/a
 
      11-01-2005
the problem is credentials forwarding. by default (and with ntlm impossible)
its not allowed to forward user credentials from a second machine to a third
(1 hop rule).

when you are on your local box, iis and asp.net has a primatuy token and can
talk to network resouces on other machines. if you connect to your pc from
another, then iis and asp.net no longer have a primary token can can not use
the token to talk to another resource.

if you switch to kerberos and enable forwarding you will able to do what you
want.

http://support.microsoft.com/default...b;en-us;810572

-- bruce (sqlwork.com)




"Siobhan" <> wrote in message
news:81B60345-D9E6-4CE3-BCF8-...
> Hi - I create a input box as follows:
> <INPUT id="inpJobDescEmpSpec" style="BORDER-RIGHT: gray thin solid;
> BORDER-TOP: gray thin solid; Z-INDEX: 181; LEFT: 232px; BORDER-LEFT: gray
> thin solid; WIDTH: 640px; BORDER-BOTTOM: gray thin solid; POSITION:
> absolute;
> TOP: 400px; HEIGHT: 22px" tabIndex="27" type="file" maxLength="250"
> size="87"
> name="inpJobDescEmpSpec" RunAt="Server">
>
> to allow the user to select a file which I want saved to a SQL Server
> database.
>
> On the save I then run this code to insert the document into the database:
>
> 'only try and attach file if there is one specified
> Dim impersonationContext As
> System.Security.Principal.WindowsImpersonationCont ext
> Dim currentWindowsIdentity As
> System.Security.Principal.WindowsIdentity
>
> currentWindowsIdentity = CType(User.Identity,
> System.Security.Principal.WindowsIdentity)
> impersonationContext = currentWindowsIdentity.Impersonate()
>
> 'Insert your code that runs under the security context of
> the authenticating user here.
> If Len(Trim(inpJobDescEmpSpec.Value)) <> 0 Then
> Dim fs As New System.IO.FileStream _
> (inpJobDescEmpSpec.Value,
> System.IO.FileMode.OpenOrCreate, _
> System.IO.FileAccess.Read)
> Dim MyData(fs.Length) As Byte
> fs.Read(MyData, 0, fs.Length)
> fs.Close()
> .JobDescEmpSpecDoc = MyData
> .UpdateDocument = True
> Else
> Dim MyData(0) As Byte
> .JobDescEmpSpecDoc = MyData
> .UpdateDocument = False
> End If
> impersonationContext.Undo()
>
> (where I am setting MyData to a byte property of my data class)
>
> This works perfectly fine in the development environment (my PC has Visual
> Studio and is the web server connectin to a SQL server database on out
> network.
>
> I can browse for and attach files with or network paths
> (C:\Folder\File.doc
> or \\Server\Share\Folder\File.doc)
>
> If I connect to the website on my PC from another PC the local drive
> upload
> works fine (C:\Folder\File.doc) but the network upload fails because
> somewhere along the way the backslashes are beibng removed so it is trying
> to
> access file \ServerShareFolderFile.doc
>
> Anyone any idea why this is?
>
> Thanks in advance
> Siobhan
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving Local and Network Printers installed on Client ? Luqman ASP .Net 2 09-06-2007 08:19 PM
Utilitizing a remote Wireless Network and my own local network for max. bandwidth benn686@hotmail.com Computer Support 0 04-06-2007 10:16 PM
File upload from client application (non-form based upload) stuart@microsoft.com Python 1 11-25-2006 12:14 AM
Microsoft Network Utility "No devices found on local network" =?Utf-8?B?QmFybnlm?= Wireless Networking 2 08-29-2006 05:21 PM
VPN Client and local network access moncho Cisco 1 06-28-2004 07:26 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57