473,837 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is This Possible ... ?

I've come up against a major headache that I can't seem to find a solution
for but I'm sure there must be a workaround and I would really be grateful
of any help.

I'm currently building a web site for a small club I belong to and one of
the features I would like to include is the ability to allow users to upload
image files.

unfortunately the servers web root www folder only allows READ and EXECUTE
permissions, which makes it impossible to allow a user to upload a gif/jpeg
image. When I FTP into the site however, I can immediately see two folders:

databases
www

the www folder is the root folder and all web pages need to be placed there,
but the databases folder does have Read, WRITE and Execute permissions and I
have been reliably informed that some ASP.NET code would allow a user to
send a picture file to an Access database in this folder, the problem I have
is not knowing how to reference it because it's not directly accessible from
the Internet - i.e. www.website.co.uk/databases would not work.

The server is running ASP.NET 1.1 and the permissions setup has to stay the
way it is, I'm not able to get my host to change the permissions on the root
folder so I have to try and make use of the databases folder instead. For
arguments sake lets also assume I already have a simple Access database
called images.mdb with one table called Images, which in turn contains two
fields, one called ID (Autonumber) (Primary Key) and another called images
(OLE Object)

What I would really like, if possible, is a very simple sample page with a
text box and a Browse button, with a second button to 'Upload' the file once
selected, plus any supporting pages that may be required to complete the
operation, i.e.:

selectfile.aspx (simple page to select image file and send to database)
uploadfile.aspx (works behind the scenes to transfer the file)
confirmation.as px (a confirmation page to indicate the transfer either
succeeded or failed)

I'm not a natural programmer by any stretch of the imagination, which is why
I'm being a bit cheeky and asking for a very simple layout to accomplish
this task, or a straight forward dummies tutorial which takes into
consideration the problem with uploading to a database outside of the root
web.

If anybody can help me solve this problem, I will forever be indebted to
you. I have searched the Internet for over a week and remarkably I cannot
find an answer to this problem, it's now driving me nuts - I just want to
solve this so I can move on with the rest of the site design.

Any help would be greatly appreciated.

Many thanks in advance
Wayne
Jun 24 '06 #1
9 3851
The news article started earlier in the day of 6/23 "FTP from one website to
another?" has just started discussing the same thing.

For the form and uploading interface you can pick up tuts and copy and paste
source anywhere. Its how to reference the target file system and use the FTP
protocol to PUT the file where it is wanted. There are many control
developers who have developed controls that support FTP. What are you
planning to do next?

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/
"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:Om******** *****@TK2MSFTNG P05.phx.gbl...
I've come up against a major headache that I can't seem to find a solution
for but I'm sure there must be a workaround and I would really be grateful
of any help.

I'm currently building a web site for a small club I belong to and one of
the features I would like to include is the ability to allow users to
upload image files.

unfortunately the servers web root www folder only allows READ and EXECUTE
permissions, which makes it impossible to allow a user to upload a
gif/jpeg image. When I FTP into the site however, I can immediately see
two folders:

databases
www

the www folder is the root folder and all web pages need to be placed
there, but the databases folder does have Read, WRITE and Execute
permissions and I have been reliably informed that some ASP.NET code would
allow a user to send a picture file to an Access database in this folder,
the problem I have is not knowing how to reference it because it's not
directly accessible from the Internet - i.e. www.website.co.uk/databases
would not work.

The server is running ASP.NET 1.1 and the permissions setup has to stay
the way it is, I'm not able to get my host to change the permissions on
the root folder so I have to try and make use of the databases folder
instead. For arguments sake lets also assume I already have a simple
Access database called images.mdb with one table called Images, which in
turn contains two fields, one called ID (Autonumber) (Primary Key) and
another called images (OLE Object)

What I would really like, if possible, is a very simple sample page with a
text box and a Browse button, with a second button to 'Upload' the file
once selected, plus any supporting pages that may be required to complete
the operation, i.e.:

selectfile.aspx (simple page to select image file and send to database)
uploadfile.aspx (works behind the scenes to transfer the file)
confirmation.as px (a confirmation page to indicate the transfer either
succeeded or failed)

I'm not a natural programmer by any stretch of the imagination, which is
why I'm being a bit cheeky and asking for a very simple layout to
accomplish this task, or a straight forward dummies tutorial which takes
into consideration the problem with uploading to a database outside of the
root web.

If anybody can help me solve this problem, I will forever be indebted to
you. I have searched the Internet for over a week and remarkably I cannot
find an answer to this problem, it's now driving me nuts - I just want to
solve this so I can move on with the rest of the site design.

Any help would be greatly appreciated.

Many thanks in advance
Wayne

Jun 24 '06 #2
Clinton,
Thanks for your reply post.

To be honest I'm not really looking at the FTP protocol simply because as
the web site administrator, I have access to FTP into the site using my
login credentials, and to be honest I wouldn't want every user of the site
knowing those details just for the sake of uploading picture files - plus
there is always the risk that someone will just FTP into the site and add
and delete files at will.

On that basis I really need to stick with either classic ASP or ASP.NET 1.1,
which are both running on my hosting providers server.

I'm absolutely desperate for a solution to this problem so if you can offer
anything else in line with what I have mentioned here and in my original
post, or indeed if anyone else reading this may have a solution - PLEASE
HELP !!!

I'm starting to go grey

Thanks
Wayne
"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
The news article started earlier in the day of 6/23 "FTP from one website
to another?" has just started discussing the same thing.

For the form and uploading interface you can pick up tuts and copy and
paste source anywhere. Its how to reference the target file system and use
the FTP protocol to PUT the file where it is wanted. There are many
control developers who have developed controls that support FTP. What are
you planning to do next?

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/
"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:Om******** *****@TK2MSFTNG P05.phx.gbl...
I've come up against a major headache that I can't seem to find a
solution for but I'm sure there must be a workaround and I would really
be grateful of any help.

I'm currently building a web site for a small club I belong to and one of
the features I would like to include is the ability to allow users to
upload image files.

unfortunately the servers web root www folder only allows READ and
EXECUTE permissions, which makes it impossible to allow a user to upload
a gif/jpeg image. When I FTP into the site however, I can immediately see
two folders:

databases
www

the www folder is the root folder and all web pages need to be placed
there, but the databases folder does have Read, WRITE and Execute
permissions and I have been reliably informed that some ASP.NET code
would allow a user to send a picture file to an Access database in this
folder, the problem I have is not knowing how to reference it because
it's not directly accessible from the Internet - i.e.
www.website.co.uk/databases would not work.

The server is running ASP.NET 1.1 and the permissions setup has to stay
the way it is, I'm not able to get my host to change the permissions on
the root folder so I have to try and make use of the databases folder
instead. For arguments sake lets also assume I already have a simple
Access database called images.mdb with one table called Images, which in
turn contains two fields, one called ID (Autonumber) (Primary Key) and
another called images (OLE Object)

What I would really like, if possible, is a very simple sample page with
a text box and a Browse button, with a second button to 'Upload' the file
once selected, plus any supporting pages that may be required to complete
the operation, i.e.:

selectfile.aspx (simple page to select image file and send to database)
uploadfile.aspx (works behind the scenes to transfer the file)
confirmation.as px (a confirmation page to indicate the transfer either
succeeded or failed)

I'm not a natural programmer by any stretch of the imagination, which is
why I'm being a bit cheeky and asking for a very simple layout to
accomplish this task, or a straight forward dummies tutorial which takes
into consideration the problem with uploading to a database outside of
the root web.

If anybody can help me solve this problem, I will forever be indebted to
you. I have searched the Internet for over a week and remarkably I cannot
find an answer to this problem, it's now driving me nuts - I just want to
solve this so I can move on with the rest of the site design.

Any help would be greatly appreciated.

Many thanks in advance
Wayne


Jun 24 '06 #3
Hi Wayne,

Okay, here's the code that should get you going. You'll need an Access
database (called imagedb.mdb) in the App_Data folder with this schema:

id: AutoNumber
FileName:Text
FileSize: Number (long integer)
ContentType: Text
FileData: OLE Object

There are two ASP.NET files. Upload.aspx handles the upload and display.
Imagefetch.aspx is a helper page that provides the image to the datagrid.

This is rough code - barebones stuff with no error checking to speak of.
Most of the code is ripped off from other articles, especially from

File Uploading to Access Database using ASP.NET
by Faisal Khan.

http://www.stardeveloper.com/article...3031201&page=1

Anyway, let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

-- upload.aspx
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server">

Protected Sub btnDisplay_Clic k _
(ByVal sender As Object, ByVal e As System.EventArg s)

' Gets the image data and displays it
' in the datagrid
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "SELECT ID, FileName," _
& " FileSize, ContentType FROM Files"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim ds As New Data.DataSet
Dim da As New Data.OleDb.OleD bDataAdapter _
(cmdtext, strConnection)
da.Fill(ds)
dg2.DataSource = ds
dg2.DataBind()
End Sub
Protected Sub btnUpload_Click _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Puts uploaded file in Access database
' Adapted for VB by Ken Cox [MVP] from
' File Uploading to Access Database using ASP.NET
' by Faisal Khan.
' http://www.stardeveloper.com/articles/display.html
'?article=20030 31201&page=1
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
If Request.Files.C ount > 0 Then
Dim files As HttpFileCollect ion
Dim afile As HttpPostedFile
files = Request.Files
afile = files(0)
Dim contentType As String = afile.ContentTy pe
Dim filename As String = ""
Dim filelength As Integer = afile.ContentLe ngth
Dim fileData As Byte() = New Byte(filelength ) {}
Dim lastpos As Integer
lastpos = afile.FileName. LastIndexOf("\" )
filename = afile.FileName. Substring(lastp os + 1)
afile.InputStre am.Read(fileDat a, 0, filelength)
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "INSERT INTO Files(FileName, " & _
" FileSize, ContentType, FileData) VALUES " & _
" (@FileName, @FileSize, @ContentType, @FileData)"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim pms As Data.OleDb.OleD bParameterColle ction
pms = cmd.Parameters
pms.Add("@FileN ame", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileS ize", Data.OleDb.OleD bType.Integer)
pms.Add("@Conte ntType", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileD ata", Data.OleDb.OleD bType.VarBinary )

pms("@FileName" ).Value = filename
pms("@FileSize" ).Value = filelength
pms("@ContentTy pe").Value = contentType
pms("@FileData" ).Value = fileData

con.Open()
cmd.ExecuteNonQ uery()
con.Close()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Upload and View Images in MS Access</title>
</head>
<body>
<form id="Form1" runat="server" enctype="multip art/form-data">
<input name="thefile" type="file"><br >
<br />
<asp:button id="btnUpload" runat="server" text="Upload"
onclick="btnUpl oad_Click" />&nbsp;<br />
<br />
<asp:button id="btnDisplay " runat="server"
onclick="btnDis play_Click" text="View Images" />&nbsp;<br />
<br />
<asp:datagrid id="dg2" runat="server" autogeneratecol umns="False">
<columns>
<asp:boundcolum n datafield="file name" headertext="Fil ename"
readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="File size" headertext="Fil esize"
readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="cont enttype"
headertext="Con tenttype" readonly="True" ></asp:boundcolumn >
<asp:templateco lumn headertext="Ima ge">
<itemtemplate >
<asp:image runat="server" imageurl='<%#
"imagefetch.asp x?id=" & DataBinder.Eval (Container, "DataItem.i d") %>' />
</itemtemplate>
</asp:templatecol umn>
</columns>
</asp:datagrid>
<br />
</form>
</body>
</html>

-- imagefetch.aspx

<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Gets the image from the Access
' Database for inclusion in another page
' Adapted from an MS KB article by Ken Cox [MVP]
'
Dim recno As Integer
If Request("id") = "" Then
Exit Sub
End If
recno = Request("id")
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection _
(strConnection)
Dim da As New Data.OleDb.OleD bDataAdapter _
("Select filedata From files where id=" & _
recno.ToString, con)
Dim MyCB As New Data.OleDb.OleD bCommandBuilder (da)
Dim ds As New Data.DataSet()
con.Open()
da.Fill(ds, "images")
Dim myRow As Data.DataRow
myRow = ds.Tables("imag es").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata ")
Response.Buffer = True
Response.Conten tType = "Image/JPEG"
Response.Binary Write(MyData)
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
End Sub
</script>

"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:Om******** *****@TK2MSFTNG P05.phx.gbl...
I've come up against a major headache that I can't seem to find a solution
for but I'm sure there must be a workaround and I would really be grateful
of any help.

I'm currently building a web site for a small club I belong to and one of
the features I would like to include is the ability to allow users to
upload image files.

unfortunately the servers web root www folder only allows READ and EXECUTE
permissions, which makes it impossible to allow a user to upload a
gif/jpeg image. When I FTP into the site however, I can immediately see
two folders:

databases
www

the www folder is the root folder and all web pages need to be placed
there, but the databases folder does have Read, WRITE and Execute
permissions and I have been reliably informed that some ASP.NET code would
allow a user to send a picture file to an Access database in this folder,
the problem I have is not knowing how to reference it because it's not
directly accessible from the Internet - i.e. www.website.co.uk/databases
would not work.

The server is running ASP.NET 1.1 and the permissions setup has to stay
the way it is, I'm not able to get my host to change the permissions on
the root folder so I have to try and make use of the databases folder
instead. For arguments sake lets also assume I already have a simple
Access database called images.mdb with one table called Images, which in
turn contains two fields, one called ID (Autonumber) (Primary Key) and
another called images (OLE Object)

What I would really like, if possible, is a very simple sample page with a
text box and a Browse button, with a second button to 'Upload' the file
once selected, plus any supporting pages that may be required to complete
the operation, i.e.:

selectfile.aspx (simple page to select image file and send to database)
uploadfile.aspx (works behind the scenes to transfer the file)
confirmation.as px (a confirmation page to indicate the transfer either
succeeded or failed)

I'm not a natural programmer by any stretch of the imagination, which is
why I'm being a bit cheeky and asking for a very simple layout to
accomplish this task, or a straight forward dummies tutorial which takes
into consideration the problem with uploading to a database outside of the
root web.

If anybody can help me solve this problem, I will forever be indebted to
you. I have searched the Internet for over a week and remarkably I cannot
find an answer to this problem, it's now driving me nuts - I just want to
solve this so I can move on with the rest of the site design.

Any help would be greatly appreciated.

Many thanks in advance
Wayne

Jun 24 '06 #4
Hey Wayne,
I'm starting to go grey
What's wrong with going gray?

(I'm already gray - started in my twenties.)

Anyway, check my response to your first post?

Ken
Microsoft MVP [ASP.NET]
"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. .. Clinton,
Thanks for your reply post.

To be honest I'm not really looking at the FTP protocol simply because as
the web site administrator, I have access to FTP into the site using my
login credentials, and to be honest I wouldn't want every user of the site
knowing those details just for the sake of uploading picture files - plus
there is always the risk that someone will just FTP into the site and add
and delete files at will.

On that basis I really need to stick with either classic ASP or ASP.NET
1.1, which are both running on my hosting providers server.

I'm absolutely desperate for a solution to this problem so if you can
offer anything else in line with what I have mentioned here and in my
original post, or indeed if anyone else reading this may have a solution -
PLEASE HELP !!!

I'm starting to go grey

Thanks
Wayne
"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
The news article started earlier in the day of 6/23 "FTP from one website
to another?" has just started discussing the same thing.

For the form and uploading interface you can pick up tuts and copy and
paste source anywhere. Its how to reference the target file system and
use the FTP protocol to PUT the file where it is wanted. There are many
control developers who have developed controls that support FTP. What are
you planning to do next?

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/
"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:Om******** *****@TK2MSFTNG P05.phx.gbl...
I've come up against a major headache that I can't seem to find a
solution for but I'm sure there must be a workaround and I would really
be grateful of any help.

I'm currently building a web site for a small club I belong to and one
of the features I would like to include is the ability to allow users to
upload image files.

unfortunately the servers web root www folder only allows READ and
EXECUTE permissions, which makes it impossible to allow a user to upload
a gif/jpeg image. When I FTP into the site however, I can immediately
see two folders:

databases
www

the www folder is the root folder and all web pages need to be placed
there, but the databases folder does have Read, WRITE and Execute
permissions and I have been reliably informed that some ASP.NET code
would allow a user to send a picture file to an Access database in this
folder, the problem I have is not knowing how to reference it because
it's not directly accessible from the Internet - i.e.
www.website.co.uk/databases would not work.

The server is running ASP.NET 1.1 and the permissions setup has to stay
the way it is, I'm not able to get my host to change the permissions on
the root folder so I have to try and make use of the databases folder
instead. For arguments sake lets also assume I already have a simple
Access database called images.mdb with one table called Images, which in
turn contains two fields, one called ID (Autonumber) (Primary Key) and
another called images (OLE Object)

What I would really like, if possible, is a very simple sample page with
a text box and a Browse button, with a second button to 'Upload' the
file once selected, plus any supporting pages that may be required to
complete the operation, i.e.:

selectfile.aspx (simple page to select image file and send to database)
uploadfile.aspx (works behind the scenes to transfer the file)
confirmation.as px (a confirmation page to indicate the transfer either
succeeded or failed)

I'm not a natural programmer by any stretch of the imagination, which is
why I'm being a bit cheeky and asking for a very simple layout to
accomplish this task, or a straight forward dummies tutorial which takes
into consideration the problem with uploading to a database outside of
the root web.

If anybody can help me solve this problem, I will forever be indebted to
you. I have searched the Internet for over a week and remarkably I
cannot find an answer to this problem, it's now driving me nuts - I just
want to solve this so I can move on with the rest of the site design.

Any help would be greatly appreciated.

Many thanks in advance
Wayne



Jun 24 '06 #5
Hi Ken,
Many thanks for taking the time to post your response, it really is
appreciated.

I followed your instructions pretty much to the letter but I'm still coming
up with an error message, I'll try and be as detailed as I can with what I
have done so you may be able to spot something obvious that I can't see.

I created a database exactly as you said, the only change I made was to
upload it into the 'databases' folder, and not a folder called 'App_Data',
simply because when I FTP into my site the two folders I see are:

databases
www

And I didn't want to change anything with the 'databases' folder as that
currently has the Read, WRITE and Execute permissions, but to be fair that
shouldn't make much difference because I also changed the line of code in
three places which references 'App_Data/imagedb.mdb' to
'databases/imagedb.mdb'

That was the only change I made so I then uploaded the 'imagedb.mdb' file to
the 'databases' folder, and I uploaded both the 'upload.aspx' and
'imagefetch.asp x' files to the www/gallery folder - so far so good.

I then opened the site and navigated to the 'gallery' link from my home
page, the page displayed correctly giving me a text box with a browse
button, and underneath an 'upload' button and a 'view images' button.

I selected a gif file from my desktop and clicked 'upload', after a few
seconds the following error page was displayed:

--------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on:
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.

Source Error:
Line 68: pms("@FileData" ).Value = fileData
Line 69:
Line 70: con.Open()
Line 71: cmd.ExecuteNonQ uery()
Line 72: con.Close()
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 70

Stack Trace:
[OleDbException (0x80004005):
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.]
System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr) +20
System.Data.Ole Db.OleDbConnect ion.InitializeP rovider() +57
System.Data.Ole Db.OleDbConnect ion.Open() +203
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032; ASP.NET
Version:1.1.432 2.2032

----------------------------------------------------------------------------------------------------------------------

Now I also have a discussion forum on my site, which I had to make a minor
adjustement to in order to post the messages to the database, I remember the
original code indicated something similar to your code in that it pointed to
'databases/forumdb.mdb' but I had to change this slightly to read:
'../databases/forumdb.mdb' and that did the trick.

So, logically I tried the same thing with your code and changed the three
references to 'databases/imagedb.mdb' to '../databases/imagedb.mdb'. I went
through the same steps to navigate to the gallery link from my home page and
this time I received the following error message:

----------------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path. Make
sure that the path name is spelled correctly and that you are connected to
the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on:
'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path. Make
sure that the path name is spelled correctly and that you are connected to
the server on which the file resides.

Source Error:
Line 68: pms("@FileData" ).Value = fileData
Line 69:
Line 70: con.Open()
Line 71: cmd.ExecuteNonQ uery()
Line 72: con.Close()
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 70

Stack Trace:
[OleDbException (0x80004005):
'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are connected
to the server on which the file resides.]
System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr) +20
System.Data.Ole Db.OleDbConnect ion.InitializeP rovider() +57
System.Data.Ole Db.OleDbConnect ion.Open() +203
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032; ASP.NET
Version:1.1.432 2.2032

-----------------------------------------------------------------------------------------------------------------------

Now if you look carefully at the line at the top which references the
directory path, you will notice it now points to:

'd:\websites\sw in644498\www\da tabases\imagedb .mdb' - instead of
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb'

Which indicates I am making progress by adding the ../ to the begining of
the database reference line, but because it's still pointing to
'www\databases' instead of just 'databases' I tried to go back one more
level by changing the reference to the following:

'../../databases/forumdb.mdb'

Again I navigated to the gallery link from my home page and went through the
steps to select a file and click the upload button, but this time the
following error was displayed:

-------------------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

Cannot use a leading .. to exit above the top directory.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Http Exception: Cannot use a leading .. to exit
above the top directory.

Source Error:
Line 35: '?article=20030 31201&page=1
Line 36: Dim strConnection As String
Line 37: strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
Line 38: "Data Source=" _
Line 39: & Server.MapPath( "../../databases/imagedb.mdb")
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 37

Stack Trace:
[HttpException (0x80004005): Cannot use a leading .. to exit above the top
directory.]
System.Web.Util .UrlPath.Reduce (String path) +700
System.Web.Util .UrlPath.Combin e(String basepath, String relative) +296
System.Web.Http Request.MapPath (String virtualPath, String baseVirtualDir,
Boolean allowCrossAppMa pping) +201
System.Web.Http ServerUtility.M apPath(String path) +60
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:37
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032; ASP.NET
Version:1.1.432 2.2032

----------------------------------------------------------------------------------------------------------------

And now I am stumped once more, logically I have tried everything I can
think of and again I'm left with a bruised forehead after banging against
the wall too many times, the difference this time is not only have I started
to go gray but my hair is actually falling out now.

PLEASE HELP !!!!

Thanks in advance for any help you may be able to offer.

Kind Regards,
Wayne



"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa m> wrote in message
news:uU******** ******@TK2MSFTN GP02.phx.gbl...
Hi Wayne,

Okay, here's the code that should get you going. You'll need an Access
database (called imagedb.mdb) in the App_Data folder with this schema:

id: AutoNumber
FileName:Text
FileSize: Number (long integer)
ContentType: Text
FileData: OLE Object

There are two ASP.NET files. Upload.aspx handles the upload and display.
Imagefetch.aspx is a helper page that provides the image to the datagrid.

This is rough code - barebones stuff with no error checking to speak of.
Most of the code is ripped off from other articles, especially from

File Uploading to Access Database using ASP.NET
by Faisal Khan.

http://www.stardeveloper.com/article...3031201&page=1

Anyway, let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

-- upload.aspx
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server">

Protected Sub btnDisplay_Clic k _
(ByVal sender As Object, ByVal e As System.EventArg s)

' Gets the image data and displays it
' in the datagrid
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "SELECT ID, FileName," _
& " FileSize, ContentType FROM Files"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim ds As New Data.DataSet
Dim da As New Data.OleDb.OleD bDataAdapter _
(cmdtext, strConnection)
da.Fill(ds)
dg2.DataSource = ds
dg2.DataBind()
End Sub
Protected Sub btnUpload_Click _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Puts uploaded file in Access database
' Adapted for VB by Ken Cox [MVP] from
' File Uploading to Access Database using ASP.NET
' by Faisal Khan.
' http://www.stardeveloper.com/articles/display.html
'?article=20030 31201&page=1
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
If Request.Files.C ount > 0 Then
Dim files As HttpFileCollect ion
Dim afile As HttpPostedFile
files = Request.Files
afile = files(0)
Dim contentType As String = afile.ContentTy pe
Dim filename As String = ""
Dim filelength As Integer = afile.ContentLe ngth
Dim fileData As Byte() = New Byte(filelength ) {}
Dim lastpos As Integer
lastpos = afile.FileName. LastIndexOf("\" )
filename = afile.FileName. Substring(lastp os + 1)
afile.InputStre am.Read(fileDat a, 0, filelength)
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "INSERT INTO Files(FileName, " & _
" FileSize, ContentType, FileData) VALUES " & _
" (@FileName, @FileSize, @ContentType, @FileData)"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim pms As Data.OleDb.OleD bParameterColle ction
pms = cmd.Parameters
pms.Add("@FileN ame", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileS ize", Data.OleDb.OleD bType.Integer)
pms.Add("@Conte ntType", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileD ata", Data.OleDb.OleD bType.VarBinary )

pms("@FileName" ).Value = filename
pms("@FileSize" ).Value = filelength
pms("@ContentTy pe").Value = contentType
pms("@FileData" ).Value = fileData

con.Open()
cmd.ExecuteNonQ uery()
con.Close()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Upload and View Images in MS Access</title>
</head>
<body>
<form id="Form1" runat="server" enctype="multip art/form-data">
<input name="thefile" type="file"><br >
<br />
<asp:button id="btnUpload" runat="server" text="Upload"
onclick="btnUpl oad_Click" />&nbsp;<br />
<br />
<asp:button id="btnDisplay " runat="server"
onclick="btnDis play_Click" text="View Images" />&nbsp;<br />
<br />
<asp:datagrid id="dg2" runat="server" autogeneratecol umns="False">
<columns>
<asp:boundcolum n datafield="file name" headertext="Fil ename"
readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="File size" headertext="Fil esize"
readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="cont enttype"
headertext="Con tenttype" readonly="True" ></asp:boundcolumn >
<asp:templateco lumn headertext="Ima ge">
<itemtemplate >
<asp:image runat="server" imageurl='<%#
"imagefetch.asp x?id=" & DataBinder.Eval (Container, "DataItem.i d") %>' />
</itemtemplate>
</asp:templatecol umn>
</columns>
</asp:datagrid>
<br />
</form>
</body>
</html>

-- imagefetch.aspx

<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Gets the image from the Access
' Database for inclusion in another page
' Adapted from an MS KB article by Ken Cox [MVP]
'
Dim recno As Integer
If Request("id") = "" Then
Exit Sub
End If
recno = Request("id")
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection _
(strConnection)
Dim da As New Data.OleDb.OleD bDataAdapter _
("Select filedata From files where id=" & _
recno.ToString, con)
Dim MyCB As New Data.OleDb.OleD bCommandBuilder (da)
Dim ds As New Data.DataSet()
con.Open()
da.Fill(ds, "images")
Dim myRow As Data.DataRow
myRow = ds.Tables("imag es").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata ")
Response.Buffer = True
Response.Conten tType = "Image/JPEG"
Response.Binary Write(MyData)
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
End Sub
</script>

"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:Om******** *****@TK2MSFTNG P05.phx.gbl...
I've come up against a major headache that I can't seem to find a
solution for but I'm sure there must be a workaround and I would really
be grateful of any help.

I'm currently building a web site for a small club I belong to and one of
the features I would like to include is the ability to allow users to
upload image files.

unfortunately the servers web root www folder only allows READ and
EXECUTE permissions, which makes it impossible to allow a user to upload
a gif/jpeg image. When I FTP into the site however, I can immediately see
two folders:

databases
www

the www folder is the root folder and all web pages need to be placed
there, but the databases folder does have Read, WRITE and Execute
permissions and I have been reliably informed that some ASP.NET code
would allow a user to send a picture file to an Access database in this
folder, the problem I have is not knowing how to reference it because
it's not directly accessible from the Internet - i.e.
www.website.co.uk/databases would not work.

The server is running ASP.NET 1.1 and the permissions setup has to stay
the way it is, I'm not able to get my host to change the permissions on
the root folder so I have to try and make use of the databases folder
instead. For arguments sake lets also assume I already have a simple
Access database called images.mdb with one table called Images, which in
turn contains two fields, one called ID (Autonumber) (Primary Key) and
another called images (OLE Object)

What I would really like, if possible, is a very simple sample page with
a text box and a Browse button, with a second button to 'Upload' the file
once selected, plus any supporting pages that may be required to complete
the operation, i.e.:

selectfile.aspx (simple page to select image file and send to database)
uploadfile.aspx (works behind the scenes to transfer the file)
confirmation.as px (a confirmation page to indicate the transfer either
succeeded or failed)

I'm not a natural programmer by any stretch of the imagination, which is
why I'm being a bit cheeky and asking for a very simple layout to
accomplish this task, or a straight forward dummies tutorial which takes
into consideration the problem with uploading to a database outside of
the root web.

If anybody can help me solve this problem, I will forever be indebted to
you. I have searched the Internet for over a week and remarkably I cannot
find an answer to this problem, it's now driving me nuts - I just want to
solve this so I can move on with the rest of the site design.

Any help would be greatly appreciated.

Many thanks in advance
Wayne


Jun 24 '06 #6
Hi Wayne,

It looks like your databases folder is outside the root of your web
application and needs to be changed in all the code.

You'll have to experiment with the path *without* using server.mappatth .

It might end up being something like this:

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=d:\websi tes\swin644498\ databases\image db.mdb"

or like this:

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=../databases/imagedb.mdb"

or even

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=../../databases/imagedb.mdb"

Keep trying, you're nearly there!

Ken
Microsoft MVP [ASP.NET]
"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:uC******** ******@TK2MSFTN GP03.phx.gbl...
Hi Ken,
Many thanks for taking the time to post your response, it really is
appreciated.

I followed your instructions pretty much to the letter but I'm still
coming up with an error message, I'll try and be as detailed as I can with
what I have done so you may be able to spot something obvious that I can't
see.

I created a database exactly as you said, the only change I made was to
upload it into the 'databases' folder, and not a folder called 'App_Data',
simply because when I FTP into my site the two folders I see are:

databases
www

And I didn't want to change anything with the 'databases' folder as that
currently has the Read, WRITE and Execute permissions, but to be fair that
shouldn't make much difference because I also changed the line of code in
three places which references 'App_Data/imagedb.mdb' to
'databases/imagedb.mdb'

That was the only change I made so I then uploaded the 'imagedb.mdb' file
to the 'databases' folder, and I uploaded both the 'upload.aspx' and
'imagefetch.asp x' files to the www/gallery folder - so far so good.

I then opened the site and navigated to the 'gallery' link from my home
page, the page displayed correctly giving me a text box with a browse
button, and underneath an 'upload' button and a 'view images' button.

I selected a gif file from my desktop and clicked 'upload', after a few
seconds the following error page was displayed:

--------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on:
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.

Source Error:
Line 68: pms("@FileData" ).Value = fileData
Line 69:
Line 70: con.Open()
Line 71: cmd.ExecuteNonQ uery()
Line 72: con.Close()
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 70

Stack Trace:
[OleDbException (0x80004005):
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.]
System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr) +20
System.Data.Ole Db.OleDbConnect ion.InitializeP rovider() +57
System.Data.Ole Db.OleDbConnect ion.Open() +203
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

----------------------------------------------------------------------------------------------------------------------

Now I also have a discussion forum on my site, which I had to make a minor
adjustement to in order to post the messages to the database, I remember
the original code indicated something similar to your code in that it
pointed to 'databases/forumdb.mdb' but I had to change this slightly to
read: '../databases/forumdb.mdb' and that did the trick.

So, logically I tried the same thing with your code and changed the three
references to 'databases/imagedb.mdb' to '../databases/imagedb.mdb'. I
went through the same steps to navigate to the gallery link from my home
page and this time I received the following error message:

----------------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on:
'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.

Source Error:
Line 68: pms("@FileData" ).Value = fileData
Line 69:
Line 70: con.Open()
Line 71: cmd.ExecuteNonQ uery()
Line 72: con.Close()
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 70

Stack Trace:
[OleDbException (0x80004005):
'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.]
System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr) +20
System.Data.Ole Db.OleDbConnect ion.InitializeP rovider() +57
System.Data.Ole Db.OleDbConnect ion.Open() +203
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

-----------------------------------------------------------------------------------------------------------------------

Now if you look carefully at the line at the top which references the
directory path, you will notice it now points to:

'd:\websites\sw in644498\www\da tabases\imagedb .mdb' - instead of
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb'

Which indicates I am making progress by adding the ../ to the begining of
the database reference line, but because it's still pointing to
'www\databases' instead of just 'databases' I tried to go back one more
level by changing the reference to the following:

'../../databases/forumdb.mdb'

Again I navigated to the gallery link from my home page and went through
the steps to select a file and click the upload button, but this time the
following error was displayed:

-------------------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

Cannot use a leading .. to exit above the top directory.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Http Exception: Cannot use a leading .. to
exit above the top directory.

Source Error:
Line 35: '?article=20030 31201&page=1
Line 36: Dim strConnection As String
Line 37: strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
Line 38: "Data Source=" _
Line 39: & Server.MapPath( "../../databases/imagedb.mdb")
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 37

Stack Trace:
[HttpException (0x80004005): Cannot use a leading .. to exit above the top
directory.]
System.Web.Util .UrlPath.Reduce (String path) +700
System.Web.Util .UrlPath.Combin e(String basepath, String relative) +296
System.Web.Http Request.MapPath (String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMa pping) +201
System.Web.Http ServerUtility.M apPath(String path) +60
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:37
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

----------------------------------------------------------------------------------------------------------------

And now I am stumped once more, logically I have tried everything I can
think of and again I'm left with a bruised forehead after banging against
the wall too many times, the difference this time is not only have I
started to go gray but my hair is actually falling out now.

PLEASE HELP !!!!

Thanks in advance for any help you may be able to offer.

Kind Regards,
Wayne



"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa m> wrote in
message news:uU******** ******@TK2MSFTN GP02.phx.gbl...
Hi Wayne,

Okay, here's the code that should get you going. You'll need an Access
database (called imagedb.mdb) in the App_Data folder with this schema:

id: AutoNumber
FileName:Text
FileSize: Number (long integer)
ContentType: Text
FileData: OLE Object

There are two ASP.NET files. Upload.aspx handles the upload and display.
Imagefetch.aspx is a helper page that provides the image to the datagrid.

This is rough code - barebones stuff with no error checking to speak of.
Most of the code is ripped off from other articles, especially from

File Uploading to Access Database using ASP.NET
by Faisal Khan.

http://www.stardeveloper.com/article...3031201&page=1

Anyway, let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

-- upload.aspx
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server">

Protected Sub btnDisplay_Clic k _
(ByVal sender As Object, ByVal e As System.EventArg s)

' Gets the image data and displays it
' in the datagrid
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "SELECT ID, FileName," _
& " FileSize, ContentType FROM Files"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim ds As New Data.DataSet
Dim da As New Data.OleDb.OleD bDataAdapter _
(cmdtext, strConnection)
da.Fill(ds)
dg2.DataSource = ds
dg2.DataBind()
End Sub
Protected Sub btnUpload_Click _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Puts uploaded file in Access database
' Adapted for VB by Ken Cox [MVP] from
' File Uploading to Access Database using ASP.NET
' by Faisal Khan.
' http://www.stardeveloper.com/articles/display.html
'?article=20030 31201&page=1
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
If Request.Files.C ount > 0 Then
Dim files As HttpFileCollect ion
Dim afile As HttpPostedFile
files = Request.Files
afile = files(0)
Dim contentType As String = afile.ContentTy pe
Dim filename As String = ""
Dim filelength As Integer = afile.ContentLe ngth
Dim fileData As Byte() = New Byte(filelength ) {}
Dim lastpos As Integer
lastpos = afile.FileName. LastIndexOf("\" )
filename = afile.FileName. Substring(lastp os + 1)
afile.InputStre am.Read(fileDat a, 0, filelength)
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "INSERT INTO Files(FileName, " & _
" FileSize, ContentType, FileData) VALUES " & _
" (@FileName, @FileSize, @ContentType, @FileData)"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim pms As Data.OleDb.OleD bParameterColle ction
pms = cmd.Parameters
pms.Add("@FileN ame", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileS ize", Data.OleDb.OleD bType.Integer)
pms.Add("@Conte ntType", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileD ata", Data.OleDb.OleD bType.VarBinary )

pms("@FileName" ).Value = filename
pms("@FileSize" ).Value = filelength
pms("@ContentTy pe").Value = contentType
pms("@FileData" ).Value = fileData

con.Open()
cmd.ExecuteNonQ uery()
con.Close()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Upload and View Images in MS Access</title>
</head>
<body>
<form id="Form1" runat="server" enctype="multip art/form-data">
<input name="thefile" type="file"><br >
<br />
<asp:button id="btnUpload" runat="server" text="Upload"
onclick="btnUpl oad_Click" />&nbsp;<br />
<br />
<asp:button id="btnDisplay " runat="server"
onclick="btnDis play_Click" text="View Images" />&nbsp;<br />
<br />
<asp:datagrid id="dg2" runat="server" autogeneratecol umns="False">
<columns>
<asp:boundcolum n datafield="file name"
headertext="Fil ename" readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="File size"
headertext="Fil esize" readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="cont enttype"
headertext="Con tenttype" readonly="True" ></asp:boundcolumn >
<asp:templateco lumn headertext="Ima ge">
<itemtemplate >
<asp:image runat="server" imageurl='<%#
"imagefetch.asp x?id=" & DataBinder.Eval (Container, "DataItem.i d") %>' />
</itemtemplate>
</asp:templatecol umn>
</columns>
</asp:datagrid>
<br />
</form>
</body>
</html>

-- imagefetch.aspx

<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Gets the image from the Access
' Database for inclusion in another page
' Adapted from an MS KB article by Ken Cox [MVP]
'
Dim recno As Integer
If Request("id") = "" Then
Exit Sub
End If
recno = Request("id")
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection _
(strConnection)
Dim da As New Data.OleDb.OleD bDataAdapter _
("Select filedata From files where id=" & _
recno.ToString, con)
Dim MyCB As New Data.OleDb.OleD bCommandBuilder (da)
Dim ds As New Data.DataSet()
con.Open()
da.Fill(ds, "images")
Dim myRow As Data.DataRow
myRow = ds.Tables("imag es").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata ")
Response.Buffer = True
Response.Conten tType = "Image/JPEG"
Response.Binary Write(MyData)
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
End Sub
</script>

"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:Om******** *****@TK2MSFTNG P05.phx.gbl...
I've come up against a major headache that I can't seem to find a
solution for but I'm sure there must be a workaround and I would really
be grateful of any help.

I'm currently building a web site for a small club I belong to and one
of the features I would like to include is the ability to allow users to
upload image files.

unfortunately the servers web root www folder only allows READ and
EXECUTE permissions, which makes it impossible to allow a user to upload
a gif/jpeg image. When I FTP into the site however, I can immediately
see two folders:

databases
www

the www folder is the root folder and all web pages need to be placed
there, but the databases folder does have Read, WRITE and Execute
permissions and I have been reliably informed that some ASP.NET code
would allow a user to send a picture file to an Access database in this
folder, the problem I have is not knowing how to reference it because
it's not directly accessible from the Internet - i.e.
www.website.co.uk/databases would not work.

The server is running ASP.NET 1.1 and the permissions setup has to stay
the way it is, I'm not able to get my host to change the permissions on
the root folder so I have to try and make use of the databases folder
instead. For arguments sake lets also assume I already have a simple
Access database called images.mdb with one table called Images, which in
turn contains two fields, one called ID (Autonumber) (Primary Key) and
another called images (OLE Object)

What I would really like, if possible, is a very simple sample page with
a text box and a Browse button, with a second button to 'Upload' the
file once selected, plus any supporting pages that may be required to
complete the operation, i.e.:

selectfile.aspx (simple page to select image file and send to database)
uploadfile.aspx (works behind the scenes to transfer the file)
confirmation.as px (a confirmation page to indicate the transfer either
succeeded or failed)

I'm not a natural programmer by any stretch of the imagination, which is
why I'm being a bit cheeky and asking for a very simple layout to
accomplish this task, or a straight forward dummies tutorial which takes
into consideration the problem with uploading to a database outside of
the root web.

If anybody can help me solve this problem, I will forever be indebted to
you. I have searched the Internet for over a week and remarkably I
cannot find an answer to this problem, it's now driving me nuts - I just
want to solve this so I can move on with the rest of the site design.

Any help would be greatly appreciated.

Many thanks in advance
Wayne



Jun 24 '06 #7
BTW, when you upload an image, note that the code assumes that you are using
..jpg.

Ken

"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:uC******** ******@TK2MSFTN GP03.phx.gbl...
Hi Ken,
Many thanks for taking the time to post your response, it really is
appreciated.

I followed your instructions pretty much to the letter but I'm still
coming up with an error message, I'll try and be as detailed as I can with
what I have done so you may be able to spot something obvious that I can't
see.

I created a database exactly as you said, the only change I made was to
upload it into the 'databases' folder, and not a folder called 'App_Data',
simply because when I FTP into my site the two folders I see are:

databases
www

Jun 24 '06 #8
Ken,
I have this unusual desire to give you a great big sloppy kiss right now,
and its only the fact that you probably haven't got long blonde hair and a
great pair of legs that I shall refrain for the moment.

As I'm sure you have already guessed, the information you provided has
worked a treat and solved my long suffering problem, I really can't thank
you enough - you're a credit to these news groups.

Thanks again for all of your help Ken, I can't tell you how much I
appreciate your assistance.

Best Regards,
Wayne

"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa m> wrote in message
news:ut******** ******@TK2MSFTN GP02.phx.gbl...
Hi Wayne,

It looks like your databases folder is outside the root of your web
application and needs to be changed in all the code.

You'll have to experiment with the path *without* using server.mappatth .

It might end up being something like this:

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=d:\websi tes\swin644498\ databases\image db.mdb"

or like this:

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=../databases/imagedb.mdb"

or even

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=../../databases/imagedb.mdb"

Keep trying, you're nearly there!

Ken
Microsoft MVP [ASP.NET]
"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:uC******** ******@TK2MSFTN GP03.phx.gbl...
Hi Ken,
Many thanks for taking the time to post your response, it really is
appreciated.

I followed your instructions pretty much to the letter but I'm still
coming up with an error message, I'll try and be as detailed as I can
with what I have done so you may be able to spot something obvious that I
can't see.

I created a database exactly as you said, the only change I made was to
upload it into the 'databases' folder, and not a folder called
'App_Data', simply because when I FTP into my site the two folders I see
are:

databases
www

And I didn't want to change anything with the 'databases' folder as that
currently has the Read, WRITE and Execute permissions, but to be fair
that shouldn't make much difference because I also changed the line of
code in three places which references 'App_Data/imagedb.mdb' to
'databases/imagedb.mdb'

That was the only change I made so I then uploaded the 'imagedb.mdb' file
to the 'databases' folder, and I uploaded both the 'upload.aspx' and
'imagefetch.asp x' files to the www/gallery folder - so far so good.

I then opened the site and navigated to the 'gallery' link from my home
page, the page displayed correctly giving me a text box with a browse
button, and underneath an 'upload' button and a 'view images' button.

I selected a gif file from my desktop and clicked 'upload', after a few
seconds the following error page was displayed:

--------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on:
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.

Source Error:
Line 68: pms("@FileData" ).Value = fileData
Line 69:
Line 70: con.Open()
Line 71: cmd.ExecuteNonQ uery()
Line 72: con.Close()
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 70

Stack Trace:
[OleDbException (0x80004005):
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.]
System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr) +20
System.Data.Ole Db.OleDbConnect ion.InitializeP rovider() +57
System.Data.Ole Db.OleDbConnect ion.Open() +203
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

----------------------------------------------------------------------------------------------------------------------

Now I also have a discussion forum on my site, which I had to make a
minor adjustement to in order to post the messages to the database, I
remember the original code indicated something similar to your code in
that it pointed to 'databases/forumdb.mdb' but I had to change this
slightly to read: '../databases/forumdb.mdb' and that did the trick.

So, logically I tried the same thing with your code and changed the three
references to 'databases/imagedb.mdb' to '../databases/imagedb.mdb'. I
went through the same steps to navigate to the gallery link from my home
page and this time I received the following error message:

----------------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on:
'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.

Source Error:
Line 68: pms("@FileData" ).Value = fileData
Line 69:
Line 70: con.Open()
Line 71: cmd.ExecuteNonQ uery()
Line 72: con.Close()
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 70

Stack Trace:
[OleDbException (0x80004005):
'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.]
System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr) +20
System.Data.Ole Db.OleDbConnect ion.InitializeP rovider() +57
System.Data.Ole Db.OleDbConnect ion.Open() +203
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

-----------------------------------------------------------------------------------------------------------------------

Now if you look carefully at the line at the top which references the
directory path, you will notice it now points to:

'd:\websites\sw in644498\www\da tabases\imagedb .mdb' - instead of
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb'

Which indicates I am making progress by adding the ../ to the begining of
the database reference line, but because it's still pointing to
'www\databases' instead of just 'databases' I tried to go back one more
level by changing the reference to the following:

'../../databases/forumdb.mdb'

Again I navigated to the gallery link from my home page and went through
the steps to select a file and click the upload button, but this time the
following error was displayed:

-------------------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

Cannot use a leading .. to exit above the top directory.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Http Exception: Cannot use a leading .. to
exit above the top directory.

Source Error:
Line 35: '?article=20030 31201&page=1
Line 36: Dim strConnection As String
Line 37: strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
Line 38: "Data Source=" _
Line 39: & Server.MapPath( "../../databases/imagedb.mdb")
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 37

Stack Trace:
[HttpException (0x80004005): Cannot use a leading .. to exit above the
top directory.]
System.Web.Util .UrlPath.Reduce (String path) +700
System.Web.Util .UrlPath.Combin e(String basepath, String relative) +296
System.Web.Http Request.MapPath (String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMa pping) +201
System.Web.Http ServerUtility.M apPath(String path) +60
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:37
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

----------------------------------------------------------------------------------------------------------------

And now I am stumped once more, logically I have tried everything I can
think of and again I'm left with a bruised forehead after banging against
the wall too many times, the difference this time is not only have I
started to go gray but my hair is actually falling out now.

PLEASE HELP !!!!

Thanks in advance for any help you may be able to offer.

Kind Regards,
Wayne



"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa m> wrote in
message news:uU******** ******@TK2MSFTN GP02.phx.gbl...
Hi Wayne,

Okay, here's the code that should get you going. You'll need an Access
database (called imagedb.mdb) in the App_Data folder with this schema:

id: AutoNumber
FileName:Text
FileSize: Number (long integer)
ContentType: Text
FileData: OLE Object

There are two ASP.NET files. Upload.aspx handles the upload and display.
Imagefetch.aspx is a helper page that provides the image to the
datagrid.

This is rough code - barebones stuff with no error checking to speak of.
Most of the code is ripped off from other articles, especially from

File Uploading to Access Database using ASP.NET
by Faisal Khan.

http://www.stardeveloper.com/article...3031201&page=1

Anyway, let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

-- upload.aspx
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server">

Protected Sub btnDisplay_Clic k _
(ByVal sender As Object, ByVal e As System.EventArg s)

' Gets the image data and displays it
' in the datagrid
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "SELECT ID, FileName," _
& " FileSize, ContentType FROM Files"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim ds As New Data.DataSet
Dim da As New Data.OleDb.OleD bDataAdapter _
(cmdtext, strConnection)
da.Fill(ds)
dg2.DataSource = ds
dg2.DataBind()
End Sub
Protected Sub btnUpload_Click _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Puts uploaded file in Access database
' Adapted for VB by Ken Cox [MVP] from
' File Uploading to Access Database using ASP.NET
' by Faisal Khan.
' http://www.stardeveloper.com/articles/display.html
'?article=20030 31201&page=1
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
If Request.Files.C ount > 0 Then
Dim files As HttpFileCollect ion
Dim afile As HttpPostedFile
files = Request.Files
afile = files(0)
Dim contentType As String = afile.ContentTy pe
Dim filename As String = ""
Dim filelength As Integer = afile.ContentLe ngth
Dim fileData As Byte() = New Byte(filelength ) {}
Dim lastpos As Integer
lastpos = afile.FileName. LastIndexOf("\" )
filename = afile.FileName. Substring(lastp os + 1)
afile.InputStre am.Read(fileDat a, 0, filelength)
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "INSERT INTO Files(FileName, " & _
" FileSize, ContentType, FileData) VALUES " & _
" (@FileName, @FileSize, @ContentType, @FileData)"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim pms As Data.OleDb.OleD bParameterColle ction
pms = cmd.Parameters
pms.Add("@FileN ame", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileS ize", Data.OleDb.OleD bType.Integer)
pms.Add("@Conte ntType", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileD ata", Data.OleDb.OleD bType.VarBinary )

pms("@FileName" ).Value = filename
pms("@FileSize" ).Value = filelength
pms("@ContentTy pe").Value = contentType
pms("@FileData" ).Value = fileData

con.Open()
cmd.ExecuteNonQ uery()
con.Close()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Upload and View Images in MS Access</title>
</head>
<body>
<form id="Form1" runat="server" enctype="multip art/form-data">
<input name="thefile" type="file"><br >
<br />
<asp:button id="btnUpload" runat="server" text="Upload"
onclick="btnUpl oad_Click" />&nbsp;<br />
<br />
<asp:button id="btnDisplay " runat="server"
onclick="btnDis play_Click" text="View Images" />&nbsp;<br />
<br />
<asp:datagrid id="dg2" runat="server"
autogeneratecol umns="False">
<columns>
<asp:boundcolum n datafield="file name"
headertext="Fil ename" readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="File size"
headertext="Fil esize" readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="cont enttype"
headertext="Con tenttype" readonly="True" ></asp:boundcolumn >
<asp:templateco lumn headertext="Ima ge">
<itemtemplate >
<asp:image runat="server" imageurl='<%#
"imagefetch.asp x?id=" & DataBinder.Eval (Container, "DataItem.i d") %>' />
</itemtemplate>
</asp:templatecol umn>
</columns>
</asp:datagrid>
<br />
</form>
</body>
</html>

-- imagefetch.aspx

<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Gets the image from the Access
' Database for inclusion in another page
' Adapted from an MS KB article by Ken Cox [MVP]
'
Dim recno As Integer
If Request("id") = "" Then
Exit Sub
End If
recno = Request("id")
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection _
(strConnection)
Dim da As New Data.OleDb.OleD bDataAdapter _
("Select filedata From files where id=" & _
recno.ToString, con)
Dim MyCB As New Data.OleDb.OleD bCommandBuilder (da)
Dim ds As New Data.DataSet()
con.Open()
da.Fill(ds, "images")
Dim myRow As Data.DataRow
myRow = ds.Tables("imag es").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata ")
Response.Buffer = True
Response.Conten tType = "Image/JPEG"
Response.Binary Write(MyData)
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
End Sub
</script>

"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:Om******** *****@TK2MSFTNG P05.phx.gbl...
I've come up against a major headache that I can't seem to find a
solution for but I'm sure there must be a workaround and I would really
be grateful of any help.

I'm currently building a web site for a small club I belong to and one
of the features I would like to include is the ability to allow users
to upload image files.

unfortunately the servers web root www folder only allows READ and
EXECUTE permissions, which makes it impossible to allow a user to
upload a gif/jpeg image. When I FTP into the site however, I can
immediately see two folders:

databases
www

the www folder is the root folder and all web pages need to be placed
there, but the databases folder does have Read, WRITE and Execute
permissions and I have been reliably informed that some ASP.NET code
would allow a user to send a picture file to an Access database in this
folder, the problem I have is not knowing how to reference it because
it's not directly accessible from the Internet - i.e.
www.website.co.uk/databases would not work.

The server is running ASP.NET 1.1 and the permissions setup has to stay
the way it is, I'm not able to get my host to change the permissions on
the root folder so I have to try and make use of the databases folder
instead. For arguments sake lets also assume I already have a simple
Access database called images.mdb with one table called Images, which
in turn contains two fields, one called ID (Autonumber) (Primary Key)
and another called images (OLE Object)

What I would really like, if possible, is a very simple sample page
with a text box and a Browse button, with a second button to 'Upload'
the file once selected, plus any supporting pages that may be required
to complete the operation, i.e.:

selectfile.aspx (simple page to select image file and send to database)
uploadfile.aspx (works behind the scenes to transfer the file)
confirmation.as px (a confirmation page to indicate the transfer either
succeeded or failed)

I'm not a natural programmer by any stretch of the imagination, which
is why I'm being a bit cheeky and asking for a very simple layout to
accomplish this task, or a straight forward dummies tutorial which
takes into consideration the problem with uploading to a database
outside of the root web.

If anybody can help me solve this problem, I will forever be indebted
to you. I have searched the Internet for over a week and remarkably I
cannot find an answer to this problem, it's now driving me nuts - I
just want to solve this so I can move on with the rest of the site
design.

Any help would be greatly appreciated.

Many thanks in advance
Wayne



Jun 24 '06 #9
Hey Wayne!

That's great that you got going! Thanks also for showing some restraint in
your mode of appreciation. <grin>

BTW, the people who run MVP programme always like to hear from satisfied
customers.

Be sure to drop by here again? There are a lot of talented people in this
newsgroup, so it doesn't pay to suffer with a problem for too long.

Ken
Microsoft MVP [ASP.NET]

"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:uE******** ********@TK2MSF TNGP02.phx.gbl. ..
Ken,
I have this unusual desire to give you a great big sloppy kiss right now,
and its only the fact that you probably haven't got long blonde hair and a
great pair of legs that I shall refrain for the moment.

As I'm sure you have already guessed, the information you provided has
worked a treat and solved my long suffering problem, I really can't thank
you enough - you're a credit to these news groups.

Thanks again for all of your help Ken, I can't tell you how much I
appreciate your assistance.

Best Regards,
Wayne

"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa m> wrote in
message news:ut******** ******@TK2MSFTN GP02.phx.gbl...
Hi Wayne,

It looks like your databases folder is outside the root of your web
application and needs to be changed in all the code.

You'll have to experiment with the path *without* using server.mappatth .

It might end up being something like this:

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=d:\websi tes\swin644498\ databases\image db.mdb"

or like this:

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=../databases/imagedb.mdb"

or even

strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=../../databases/imagedb.mdb"

Keep trying, you're nearly there!

Ken
Microsoft MVP [ASP.NET]
"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:uC******** ******@TK2MSFTN GP03.phx.gbl...
Hi Ken,
Many thanks for taking the time to post your response, it really is
appreciated.

I followed your instructions pretty much to the letter but I'm still
coming up with an error message, I'll try and be as detailed as I can
with what I have done so you may be able to spot something obvious that
I can't see.

I created a database exactly as you said, the only change I made was to
upload it into the 'databases' folder, and not a folder called
'App_Data', simply because when I FTP into my site the two folders I see
are:

databases
www

And I didn't want to change anything with the 'databases' folder as that
currently has the Read, WRITE and Execute permissions, but to be fair
that shouldn't make much difference because I also changed the line of
code in three places which references 'App_Data/imagedb.mdb' to
'databases/imagedb.mdb'

That was the only change I made so I then uploaded the 'imagedb.mdb'
file to the 'databases' folder, and I uploaded both the 'upload.aspx'
and 'imagefetch.asp x' files to the www/gallery folder - so far so good.

I then opened the site and navigated to the 'gallery' link from my home
page, the page displayed correctly giving me a text box with a browse
button, and underneath an 'upload' button and a 'view images' button.

I selected a gif file from my desktop and clicked 'upload', after a few
seconds the following error page was displayed:

--------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on:
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.

Source Error:
Line 68: pms("@FileData" ).Value = fileData
Line 69:
Line 70: con.Open()
Line 71: cmd.ExecuteNonQ uery()
Line 72: con.Close()
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 70

Stack Trace:
[OleDbException (0x80004005):
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.]
System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr) +20
System.Data.Ole Db.OleDbConnect ion.InitializeP rovider() +57
System.Data.Ole Db.OleDbConnect ion.Open() +203
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
+33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

----------------------------------------------------------------------------------------------------------------------

Now I also have a discussion forum on my site, which I had to make a
minor adjustement to in order to post the messages to the database, I
remember the original code indicated something similar to your code in
that it pointed to 'databases/forumdb.mdb' but I had to change this
slightly to read: '../databases/forumdb.mdb' and that did the trick.

So, logically I tried the same thing with your code and changed the
three references to 'databases/imagedb.mdb' to
'../databases/imagedb.mdb'. I went through the same steps to navigate to
the gallery link from my home page and this time I received the
following error message:

----------------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on:
'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.

Source Error:
Line 68: pms("@FileData" ).Value = fileData
Line 69:
Line 70: con.Open()
Line 71: cmd.ExecuteNonQ uery()
Line 72: con.Close()
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 70

Stack Trace:
[OleDbException (0x80004005):
'd:\websites\sw in644498\www\da tabases\imagedb .mdb' is not a valid path.
Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.]
System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr) +20
System.Data.Ole Db.OleDbConnect ion.InitializeP rovider() +57
System.Data.Ole Db.OleDbConnect ion.Open() +203
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:70
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
+33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

-----------------------------------------------------------------------------------------------------------------------

Now if you look carefully at the line at the top which references the
directory path, you will notice it now points to:

'd:\websites\sw in644498\www\da tabases\imagedb .mdb' - instead of
'd:\websites\sw in644498\www\ga llery\databases \imagedb.mdb'

Which indicates I am making progress by adding the ../ to the begining
of the database reference line, but because it's still pointing to
'www\databases' instead of just 'databases' I tried to go back one more
level by changing the reference to the following:

'../../databases/forumdb.mdb'

Again I navigated to the gallery link from my home page and went through
the steps to select a file and click the upload button, but this time
the following error was displayed:

-------------------------------------------------------------------------------------------------------------------------
Server Error in '/' Application.
--------------------------------------------------------------------------------

Cannot use a leading .. to exit above the top directory.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Http Exception: Cannot use a leading .. to
exit above the top directory.

Source Error:
Line 35: '?article=20030 31201&page=1
Line 36: Dim strConnection As String
Line 37: strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
Line 38: "Data Source=" _
Line 39: & Server.MapPath( "../../databases/imagedb.mdb")
Source File: d:\websites\swi n644498\www\gal lery\upload.asp x Line: 37

Stack Trace:
[HttpException (0x80004005): Cannot use a leading .. to exit above the
top directory.]
System.Web.Util .UrlPath.Reduce (String path) +700
System.Web.Util .UrlPath.Combin e(String basepath, String relative) +296
System.Web.Http Request.MapPath (String virtualPath, String
baseVirtualDir, Boolean allowCrossAppMa pping) +201
System.Web.Http ServerUtility.M apPath(String path) +60
ASP.upload_aspx .btnUpload_Clic k(Object sender, EventArgs e) in
d:\websites\swi n644498\www\gal lery\upload.asp x:37
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
+33
System.Web.UI.P age.ProcessRequ estMain() +1292

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032;
ASP.NET Version:1.1.432 2.2032

----------------------------------------------------------------------------------------------------------------

And now I am stumped once more, logically I have tried everything I can
think of and again I'm left with a bruised forehead after banging
against the wall too many times, the difference this time is not only
have I started to go gray but my hair is actually falling out now.

PLEASE HELP !!!!

Thanks in advance for any help you may be able to offer.

Kind Regards,
Wayne



"Ken Cox [Microsoft MVP]" <BA**********@n ewsgroups.nospa m> wrote in
message news:uU******** ******@TK2MSFTN GP02.phx.gbl...
Hi Wayne,

Okay, here's the code that should get you going. You'll need an Access
database (called imagedb.mdb) in the App_Data folder with this schema:

id: AutoNumber
FileName:Text
FileSize: Number (long integer)
ContentType: Text
FileData: OLE Object

There are two ASP.NET files. Upload.aspx handles the upload and
display. Imagefetch.aspx is a helper page that provides the image to
the datagrid.

This is rough code - barebones stuff with no error checking to speak
of. Most of the code is ripped off from other articles, especially from

File Uploading to Access Database using ASP.NET
by Faisal Khan.

http://www.stardeveloper.com/article...3031201&page=1

Anyway, let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

-- upload.aspx
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server">

Protected Sub btnDisplay_Clic k _
(ByVal sender As Object, ByVal e As System.EventArg s)

' Gets the image data and displays it
' in the datagrid
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "SELECT ID, FileName," _
& " FileSize, ContentType FROM Files"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim ds As New Data.DataSet
Dim da As New Data.OleDb.OleD bDataAdapter _
(cmdtext, strConnection)
da.Fill(ds)
dg2.DataSource = ds
dg2.DataBind()
End Sub
Protected Sub btnUpload_Click _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Puts uploaded file in Access database
' Adapted for VB by Ken Cox [MVP] from
' File Uploading to Access Database using ASP.NET
' by Faisal Khan.
' http://www.stardeveloper.com/articles/display.html
'?article=20030 31201&page=1
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
If Request.Files.C ount > 0 Then
Dim files As HttpFileCollect ion
Dim afile As HttpPostedFile
files = Request.Files
afile = files(0)
Dim contentType As String = afile.ContentTy pe
Dim filename As String = ""
Dim filelength As Integer = afile.ContentLe ngth
Dim fileData As Byte() = New Byte(filelength ) {}
Dim lastpos As Integer
lastpos = afile.FileName. LastIndexOf("\" )
filename = afile.FileName. Substring(lastp os + 1)
afile.InputStre am.Read(fileDat a, 0, filelength)
Dim con As New Data.OleDb.OleD bConnection(str Connection)
Dim cmdtext As String = "INSERT INTO Files(FileName, " & _
" FileSize, ContentType, FileData) VALUES " & _
" (@FileName, @FileSize, @ContentType, @FileData)"
Dim cmd As New Data.OleDb.OleD bCommand(cmdtex t, con)
Dim pms As Data.OleDb.OleD bParameterColle ction
pms = cmd.Parameters
pms.Add("@FileN ame", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileS ize", Data.OleDb.OleD bType.Integer)
pms.Add("@Conte ntType", Data.OleDb.OleD bType.VarChar, 50)
pms.Add("@FileD ata", Data.OleDb.OleD bType.VarBinary )

pms("@FileName" ).Value = filename
pms("@FileSize" ).Value = filelength
pms("@ContentTy pe").Value = contentType
pms("@FileData" ).Value = fileData

con.Open()
cmd.ExecuteNonQ uery()
con.Close()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Upload and View Images in MS Access</title>
</head>
<body>
<form id="Form1" runat="server" enctype="multip art/form-data">
<input name="thefile" type="file"><br >
<br />
<asp:button id="btnUpload" runat="server" text="Upload"
onclick="btnUpl oad_Click" />&nbsp;<br />
<br />
<asp:button id="btnDisplay " runat="server"
onclick="btnDis play_Click" text="View Images" />&nbsp;<br />
<br />
<asp:datagrid id="dg2" runat="server"
autogeneratecol umns="False">
<columns>
<asp:boundcolum n datafield="file name"
headertext="Fil ename" readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="File size"
headertext="Fil esize" readonly="True" ></asp:boundcolumn >
<asp:boundcolum n datafield="cont enttype"
headertext="Con tenttype" readonly="True" ></asp:boundcolumn >
<asp:templateco lumn headertext="Ima ge">
<itemtemplate >
<asp:image runat="server" imageurl='<%#
"imagefetch.asp x?id=" & DataBinder.Eval (Container, "DataItem.i d") %>'
/>
</itemtemplate>
</asp:templatecol umn>
</columns>
</asp:datagrid>
<br />
</form>
</body>
</html>

-- imagefetch.aspx

<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArg s)
' Gets the image from the Access
' Database for inclusion in another page
' Adapted from an MS KB article by Ken Cox [MVP]
'
Dim recno As Integer
If Request("id") = "" Then
Exit Sub
End If
recno = Request("id")
Dim strConnection As String
strConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" _
& Server.MapPath( "App_Data/imagedb.mdb")
Dim con As New Data.OleDb.OleD bConnection _
(strConnection)
Dim da As New Data.OleDb.OleD bDataAdapter _
("Select filedata From files where id=" & _
recno.ToString, con)
Dim MyCB As New Data.OleDb.OleD bCommandBuilder (da)
Dim ds As New Data.DataSet()
con.Open()
da.Fill(ds, "images")
Dim myRow As Data.DataRow
myRow = ds.Tables("imag es").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata ")
Response.Buffer = True
Response.Conten tType = "Image/JPEG"
Response.Binary Write(MyData)
MyCB = Nothing
ds = Nothing
da = Nothing
con.Close()
con = Nothing
End Sub
</script>

"Wayne Smith" <waynesmith1971 (NoSpam)@hotmai l.com> wrote in message
news:Om******** *****@TK2MSFTNG P05.phx.gbl...
> I've come up against a major headache that I can't seem to find a
> solution for but I'm sure there must be a workaround and I would
> really be grateful of any help.
>
> I'm currently building a web site for a small club I belong to and one
> of the features I would like to include is the ability to allow users
> to upload image files.
>
> unfortunately the servers web root www folder only allows READ and
> EXECUTE permissions, which makes it impossible to allow a user to
> upload a gif/jpeg image. When I FTP into the site however, I can
> immediately see two folders:
>
> databases
> www
>
> the www folder is the root folder and all web pages need to be placed
> there, but the databases folder does have Read, WRITE and Execute
> permissions and I have been reliably informed that some ASP.NET code
> would allow a user to send a picture file to an Access database in
> this folder, the problem I have is not knowing how to reference it
> because it's not directly accessible from the Internet - i.e.
> www.website.co.uk/databases would not work.
>
> The server is running ASP.NET 1.1 and the permissions setup has to
> stay the way it is, I'm not able to get my host to change the
> permissions on the root folder so I have to try and make use of the
> databases folder instead. For arguments sake lets also assume I
> already have a simple Access database called images.mdb with one table
> called Images, which in turn contains two fields, one called ID
> (Autonumber) (Primary Key) and another called images (OLE Object)
>
> What I would really like, if possible, is a very simple sample page
> with a text box and a Browse button, with a second button to 'Upload'
> the file once selected, plus any supporting pages that may be required
> to complete the operation, i.e.:
>
> selectfile.aspx (simple page to select image file and send to
> database)
> uploadfile.aspx (works behind the scenes to transfer the file)
> confirmation.as px (a confirmation page to indicate the transfer either
> succeeded or failed)
>
> I'm not a natural programmer by any stretch of the imagination, which
> is why I'm being a bit cheeky and asking for a very simple layout to
> accomplish this task, or a straight forward dummies tutorial which
> takes into consideration the problem with uploading to a database
> outside of the root web.
>
> If anybody can help me solve this problem, I will forever be indebted
> to you. I have searched the Internet for over a week and remarkably I
> cannot find an answer to this problem, it's now driving me nuts - I
> just want to solve this so I can move on with the rest of the site
> design.
>
> Any help would be greatly appreciated.
>
> Many thanks in advance
> Wayne
>
>



Jun 24 '06 #10

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

Similar topics

4
14477
by: Julia Briggs | last post by:
I am struggling to create a PHP function that would take a specified image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail so it will always fit in a 200x250 space. I am hoping not to have it inserted or read from a database to do this function. Can it be done & someone please help me?
36
9491
by: rbt | last post by:
Say I have a list that has 3 letters in it: I want to print all the possible 4 digit combinations of those 3 letters: 4^3 = 64 aaaa
20
2516
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to the site, and then i have to select the file to upload.. i used sendkeys.. and i worked perfect.. BUT ... the computer must be locked for security ( obviusly ) reazons.. so..i think this probable solutions to unlock the computer and run the...
7
2353
by: Andrzej | last post by:
Is it possible to call a function which name is given by a string? Let assume that I created a program which call some functions for example void f1(void), void f2(void), void f3(void). After some time, I added new function void f4(void).
2
3820
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens provide text area where the user can insert big chunks of text and submit it all to the server paragraph by paragraph. The requirement is to do a Spell Check AND Grammar Check in the text area. I did look at lot of possible third
1
6964
by: AAA | last post by:
hi, I'll explain fastly the program that i'm doing.. the computer asks me to enter the cardinal of a set X ( called "dimX" type integer)where X is a table of one dimension and then to fill it with numbers X; then the computer asks me how many subsets i have (nb_subset type (integer)) then,i have to enter for every sebset the card, and then to fill it, we'll have a two tables , one called cardY which contains nb_subset elements,and every...
25
2566
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e. every 5 seconds, i just want to refresh it ONLY on server change just like desktop applications do. The problem is that refreshing evry n seconds has to much impact on my web server. The refresh action should be taken only when something
4
7704
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate a two dimensional array of all possible combinations of values. A simple example: 2 - columns and 2 possible values would generate: 0 0
7
3368
by: Robert S. | last post by:
Searching some time now for documents on this but still did not find anything about it: Is it possible to replace the entry screen of MS Office Access 2007 - that one presenting that default 'templates' (with that big graphic buttons) - with some sort of own HTML-Page? I could imagine, that somehow it is possible to change this construction (hopefully not hardcoded in MS-Acc07), like it is possible to edit the 'Fluent Ribbon'? If so...
14
2020
by: bjorklund.emil | last post by:
Hello pythonistas. I'm a newbie to pretty much both programming and Python. I have a task that involves writing a test script for every possible combination of preference settings for a software I'm testing. I figured that this was something that a script could probably do pretty easily, given all the various possibilites. I started creating a dictionary of all the settings, where each key has a value that is a list of the possible...
0
9827
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
10863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10560
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
9390
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
7798
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
6987
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();...
0
5838
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4034
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3120
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.