473,574 Members | 18,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload if files from client PC or local network

Hi - I create a input box as follows:
<INPUT id="inpJobDescE mpSpec" 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="inpJobDes cEmpSpec" 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 impersonationCo ntext As
System.Security .Principal.Wind owsImpersonatio nContext
Dim currentWindowsI dentity As
System.Security .Principal.Wind owsIdentity

currentWindowsI dentity = CType(User.Iden tity,
System.Security .Principal.Wind owsIdentity)
impersonationCo ntext = currentWindowsI dentity.Imperso nate()

'Insert your code that runs under the security context of
the authenticating user here.
If Len(Trim(inpJob DescEmpSpec.Val ue)) <> 0 Then
Dim fs As New System.IO.FileS tream _
(inpJobDescEmpS pec.Value,
System.IO.FileM ode.OpenOrCreat e, _
System.IO.FileA ccess.Read)
Dim MyData(fs.Lengt h) As Byte
fs.Read(MyData, 0, fs.Length)
fs.Close()
.JobDescEmpSpec Doc = MyData
.UpdateDocument = True
Else
Dim MyData(0) As Byte
.JobDescEmpSpec Doc = MyData
.UpdateDocument = False
End If
impersonationCo ntext.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 \ServerShareFol derFile.doc

Anyone any idea why this is?

Thanks in advance
Siobhan

Nov 19 '05 #1
2 1510
On Tue, 01 Nov 2005 06:57:03 -0800, Siobhan wrote:
Hi - I create a input box as follows:
<INPUT id="inpJobDescE mpSpec" 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="inpJobDes cEmpSpec" 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 impersonationCo ntext As
System.Security .Principal.Wind owsImpersonatio nContext
Dim currentWindowsI dentity As
System.Security .Principal.Wind owsIdentity

currentWindowsI dentity = CType(User.Iden tity,
System.Security .Principal.Wind owsIdentity)
impersonationCo ntext = currentWindowsI dentity.Imperso nate()

'Insert your code that runs under the security context of
the authenticating user here.
If Len(Trim(inpJob DescEmpSpec.Val ue)) <> 0 Then
Dim fs As New System.IO.FileS tream _
(inpJobDescEmpS pec.Value,
System.IO.FileM ode.OpenOrCreat e, _
System.IO.FileA ccess.Read)
Dim MyData(fs.Lengt h) As Byte
fs.Read(MyData, 0, fs.Length)
fs.Close()
.JobDescEmpSpec Doc = MyData
.UpdateDocument = True
Else
Dim MyData(0) As Byte
.JobDescEmpSpec Doc = MyData
.UpdateDocument = False
End If
impersonationCo ntext.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 \ServerShareFol derFile.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*****@discus sions.microsoft .com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
Hi - I create a input box as follows:
<INPUT id="inpJobDescE mpSpec" 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="inpJobDes cEmpSpec" 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 impersonationCo ntext As
System.Security .Principal.Wind owsImpersonatio nContext
Dim currentWindowsI dentity As
System.Security .Principal.Wind owsIdentity

currentWindowsI dentity = CType(User.Iden tity,
System.Security .Principal.Wind owsIdentity)
impersonationCo ntext = currentWindowsI dentity.Imperso nate()

'Insert your code that runs under the security context of
the authenticating user here.
If Len(Trim(inpJob DescEmpSpec.Val ue)) <> 0 Then
Dim fs As New System.IO.FileS tream _
(inpJobDescEmpS pec.Value,
System.IO.FileM ode.OpenOrCreat e, _
System.IO.FileA ccess.Read)
Dim MyData(fs.Lengt h) As Byte
fs.Read(MyData, 0, fs.Length)
fs.Close()
.JobDescEmpSpec Doc = MyData
.UpdateDocument = True
Else
Dim MyData(0) As Byte
.JobDescEmpSpec Doc = MyData
.UpdateDocument = False
End If
impersonationCo ntext.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 \ServerShareFol derFile.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
3174
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" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
9
3882
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 works fine. The doctors want fewer steps to follow. So, it was asked if I can configure the browser to load/submit the image 'xray.tif' each time they...
4
1913
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). The uploaded images are resized to thumbnails 120x120 version and 600x400 version. Maximum 1 MB size image files are allowed to upload. I have...
2
5170
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 upload since most people download from the internet vs upload. My question is if it's a local intranet with a couple of users, why is it faster...
0
7820
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7738
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8258
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7835
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8121
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6486
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2255
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1360
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1084
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.