473,666 Members | 2,047 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 1513
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
3182
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
3887
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 click "Upload Image" instead of the doctor/animal technician having to look for for dental x-ray...
4
1915
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 tested with this in my local server using XAMPP for Windows and its working fine. In my local server...
2
5174
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 to download the same exact file vs when I uploaded it a minute ago. Does it have to do with HTTP...
0
8448
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8783
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8640
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2773
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
2
1776
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.