473,395 Members | 1,919 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,395 software developers and data experts.

Upload if files from client PC or local network

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

Nov 19 '05 #1
2 1495
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.

Nov 19 '05 #2
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" <Si*****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
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

Nov 19 '05 #3

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

Similar topics

7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
9
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This...
4
by: samatair | last post by:
Hi I have being working on a form. The form allows 5 image files to be uploaded with other user details. All the 5 image files are uploaded at the same time (with a single submit button click)....
2
dlite922
by: dlite922 | last post by:
I have an intranet LAMP server and I use PHP to upload files. It is of course faster to download the same file than to upload it. I understand ISPs throttle their network for download speed, than...
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:
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
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.