Best way to upload?

Best way to upload?

am 25.01.2005 04:35:58 von SusieQ

I need to upload files to a server, and place the name, size and some other
information into an Access DB at the same time.
Can anyone recommend the best and simplest way to do this?

Thanks in advance.

Re: Best way to upload?

am 25.01.2005 14:08:02 von Bullschmidt

Here is a pure ASP (i.e. no components) resource for letting the user
upload a file which is something that was unfortunately not built into
ASP:

ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
http://aspzone.com/posts/160.aspx

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Re: Best way to upload?

am 25.01.2005 14:52:26 von McKirahan

"SusieQ" wrote in message
news:uPRG56oAFHA.4044@TK2MSFTNGP10.phx.gbl...
> I need to upload files to a server, and place the name, size and some
other
> information into an Access DB at the same time.
> Can anyone recommend the best and simplest way to do this?
>
> Thanks in advance.


Does you Web host support file upload software from a third-party?

Perhaps AspUpload's product; http://www.aspupload.com/ ?

Below are two pages ("upload.htm" calls "upload.asp") that may do what you
want.

The database table "Upload" has three fields: "FileName", "FileSize", and
"DateTime".

The full physical path to each file (on the server) is stored in "FileName".

The files are uploaded to the same folder that the database is in.

Watch for word-wrap.

<< upload.htm >>



upload.htm



name="form1" onsubmit="return fileup()"
enctype="multipart/form-data">








<< upload.asp >>

<%@ Language="VBScript" %>
<% Option Explicit
'*
Const cASP = "upload.asp"
Const cMDB = "upload.mdb"
Const cDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
'*
Const adCmdTable = &H0002
Const adLockOptimistic = 3
Const adOpenKeySet = 1
'*
'* Declare Variables
'*
Dim strFOL
strFOL = Server.MapPath(cMDB)
strFOL = Left(strFOL,InStrRev(strFOL,"\"))
'*
'* Declare Objects
'*
Dim objADO
Set objADO = Server.CreateObject("ADODB.Connection")
objADO.Open cDSN & Server.MapPath(cMDB)
Dim objPUP
Set objPUP = Server.CreateObject("Persits.Upload")
Dim objRST
Set objRST = Server.CreateObject("ADODB.Recordset")
'*
'* Process Files
'*
objPUP.Save strFOL
Response.Write "

Files :"
Dim File
For Each File in objPUP.Files
Response.Write "
" & File.Name & " = " & File.Path
Response.Write " (" & FormatNumber(File.Size,0) & ")"
'*
'* Update Database
'*
objRST.Open "Upload", objADO, adOpenKeySet, adLockOptimistic,
adCmdTable
objRST.AddNew
objRST("FileName").Value = File.Path
objRST("FileSize").Value = File.Size
objRST("DateTime").Value = Now()
objRST.Update
Next
'*
'* Process Items
'*
Response.Write "

Items :"
Dim Item
For Each Item in objPUP.Form
Response.Write "
" & Item.Name & " = " & Item.Value
Next
'*
'* Destroy Objects
'*
Set objADO = Nothing
Set objPUP = Nothing
Set objRST = Nothing
End Sub
%>


<%=cASP%>



Re: Best way to upload?

am 25.01.2005 17:15:47 von Mark Schupp

Here are a number of options

http://www.aspfaq.com/show.asp?id=2189

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"SusieQ" wrote in message
news:uPRG56oAFHA.4044@TK2MSFTNGP10.phx.gbl...
>I need to upload files to a server, and place the name, size and some other
>information into an Access DB at the same time.
> Can anyone recommend the best and simplest way to do this?
>
> Thanks in advance.
>

Re: Best way to upload?

am 26.01.2005 05:18:03 von SusieQ

Thanks all
I'm trying the documentation for AspUpload using their generic code as is

Input Page:



ACTION="formitems_upload.asp">
Select file:







======================================


<%
Set Upload = Server.CreateObject("Persits.Upload")
Upload.SetMaxSize 100000, True
Upload.Save
subdir = Upload.Form("subdir")
Path = "d:\" & subdir
Upload.CreateDirectory Path, True
File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line 13
Response.Write "File saved as " & File.Path & "
"
%>


=======================================================
The problem I get is this error:
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/cuploaded1.asp, line 13
which says to me that the process is not getting the path from the form
before. I understand most of it, but I'm not sure why I'm not getting the
path name. I don't think I've missed any quotes or anything and am not sure
about the upload.form statement.
Can anyone help me please??
TIA

Re: Best way to upload?

am 26.01.2005 05:44:24 von SusieQ

BTW - this is W2K and IIS 5.0

"SusieQ" wrote in message
news:%23wSxy31AFHA.2552@TK2MSFTNGP09.phx.gbl...
> Thanks all
> I'm trying the documentation for AspUpload using their generic code as is
>
> Input Page:
>
>
>
>

> ACTION="formitems_upload.asp">
> Select file:

>

>
>

>
>
> ======================================
>
>
> <%
> Set Upload = Server.CreateObject("Persits.Upload")
> Upload.SetMaxSize 100000, True
> Upload.Save
> subdir = Upload.Form("subdir")
> Path = "d:\" & subdir
> Upload.CreateDirectory Path, True
> File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line 13
> Response.Write "File saved as " & File.Path & "
"
> %>
>
>
> =======================================================
> The problem I get is this error:
> Microsoft VBScript runtime error '800a01a8'
> Object required: ''
> /cuploaded1.asp, line 13
> which says to me that the process is not getting the path from the form
> before. I understand most of it, but I'm not sure why I'm not getting the
> path name. I don't think I've missed any quotes or anything and am not
> sure about the upload.form statement.
> Can anyone help me please??
> TIA
>

Re: Best way to upload?

am 26.01.2005 07:47:34 von Roland Hall

"SusieQ" wrote in message news:%23wSxy31AFHA.2552@TK2MSFTNGP09.phx.gbl...
: Thanks all
: I'm trying the documentation for AspUpload using their generic code as is
:
: Input Page:
:
:
:
:

: ACTION="formitems_upload.asp">
: Select file:

:

:
:

:
:
: ======================================
:
:
: <%
: Set Upload = Server.CreateObject("Persits.Upload")
: Upload.SetMaxSize 100000, True
: Upload.Save
: subdir = Upload.Form("subdir")
: Path = "d:\" & subdir
: Upload.CreateDirectory Path, True
: File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line 13
: Response.Write "File saved as " & File.Path & "
"
: %>
:
:
: =======================================================
: The problem I get is this error:
: Microsoft VBScript runtime error '800a01a8'
: Object required: ''
: /cuploaded1.asp, line 13
: which says to me that the process is not getting the path from the form
: before. I understand most of it, but I'm not sure why I'm not getting the
: path name. I don't think I've missed any quotes or anything and am not
sure
: about the upload.form statement.
: Can anyone help me please??
: TIA

Susie...

Did the directory get created?

If you put this:
Response.Write Path & "\" & File.FileName

before this:
File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line 13

Do you get the intended result?

BTW... this is not asp.db related.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Re: Best way to upload?

am 26.01.2005 08:07:23 von SusieQ

"Roland Hall" wrote in message
news:%23CcsrL3AFHA.2568@TK2MSFTNGP11.phx.gbl...
> "SusieQ" wrote in message news:%23wSxy31AFHA.2552@TK2MSFTNGP09.phx.gbl...
> : Thanks all
> : I'm trying the documentation for AspUpload using their generic code as
> is
> :
> : Input Page:
> :
> :
> :
> :

> : ACTION="formitems_upload.asp">
> : Select file:

> :

> :
> :

> :
> :
> : ======================================
> :
> :
> : <%
> : Set Upload = Server.CreateObject("Persits.Upload")
> : Upload.SetMaxSize 100000, True
> : Upload.Save
> : subdir = Upload.Form("subdir")
> : Path = "d:\" & subdir
> : Upload.CreateDirectory Path, True
> : File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line
> 13
> : Response.Write "File saved as " & File.Path & "
"
> : %>
> :
> :
> : =======================================================
> : The problem I get is this error:
> : Microsoft VBScript runtime error '800a01a8'
> : Object required: ''
> : /cuploaded1.asp, line 13
> : which says to me that the process is not getting the path from the form
> : before. I understand most of it, but I'm not sure why I'm not getting
> the
> : path name. I don't think I've missed any quotes or anything and am not
> sure
> : about the upload.form statement.
> : Can anyone help me please??
> : TIA
>
> Susie...
>
> Did the directory get created?
>
> If you put this:
> Response.Write Path & "\" & File.FileName
>
> before this:
> File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line 13
>
> Do you get the intended result?
>
> BTW... this is not asp.db related.
> --
> Roland Hall
> /* This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose. */
> Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
> WSH 5.6 Documentation -
> http://msdn.microsoft.com/downloads/list/webdev.asp
> MSDN Library - http://msdn.microsoft.com/library/default.asp
>
>

Re: Best way to upload?

am 26.01.2005 08:24:05 von SusieQ

Thanks Roland
Yes the directory does get created, but the response.write that you asked me
to put in doesn't get displayed.

I simply received the error:
Microsoft VBScript runtime error '800a01a8'
Object required: ''
cuploaded1.asp, line 13

which now looks to me like maybe I'm not getting the filename since the
directory is created??

And actually this did start out being ASP/DB related as I am needing a way
to upload a file, then write the filename, description, size, and a few
other details to an Access DB. It was suggested that I look at this
component to achieve this, but I'm having trouble with the upload part of
it. Can you suggest another forum where this part of the component would be
better answered?

Thanks again in advance.




"Roland Hall" wrote in message
news:%23CcsrL3AFHA.2568@TK2MSFTNGP11.phx.gbl...
> "SusieQ" wrote in message news:%23wSxy31AFHA.2552@TK2MSFTNGP09.phx.gbl...
> : Thanks all
> : I'm trying the documentation for AspUpload using their generic code as
> is
> :
> : Input Page:
> :
> :
> :
> :

> : ACTION="formitems_upload.asp">
> : Select file:

> :

> :
> :

> :
> :
> : ======================================
> :
> :
> : <%
> : Set Upload = Server.CreateObject("Persits.Upload")
> : Upload.SetMaxSize 100000, True
> : Upload.Save
> : subdir = Upload.Form("subdir")
> : Path = "d:\" & subdir
> : Upload.CreateDirectory Path, True
> : File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line
> 13
> : Response.Write "File saved as " & File.Path & "
"
> : %>
> :
> :
> : =======================================================
> : The problem I get is this error:
> : Microsoft VBScript runtime error '800a01a8'
> : Object required: ''
> : /cuploaded1.asp, line 13
> : which says to me that the process is not getting the path from the form
> : before. I understand most of it, but I'm not sure why I'm not getting
> the
> : path name. I don't think I've missed any quotes or anything and am not
> sure
> : about the upload.form statement.
> : Can anyone help me please??
> : TIA
>
> Susie...
>
> Did the directory get created?
>
> If you put this:
> Response.Write Path & "\" & File.FileName
>
> before this:
> File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line 13
>
> Do you get the intended result?
>
> BTW... this is not asp.db related.
> --
> Roland Hall
> /* This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose. */
> Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
> WSH 5.6 Documentation -
> http://msdn.microsoft.com/downloads/list/webdev.asp
> MSDN Library - http://msdn.microsoft.com/library/default.asp
>
>

Re: Best way to upload?

am 26.01.2005 09:13:45 von Roland Hall

"SusieQ" wrote in message news:O94S8e3AFHA.2880@TK2MSFTNGP14.phx.gbl...
:
: "Roland Hall" wrote in message
: news:%23CcsrL3AFHA.2568@TK2MSFTNGP11.phx.gbl...
: > "SusieQ" wrote in message
news:%23wSxy31AFHA.2552@TK2MSFTNGP09.phx.gbl...
: > : Thanks all
: > : I'm trying the documentation for AspUpload using their generic code as
: > is
: > :
: > : Input Page:
: > :
: > :
: > :
: > :

: > : ACTION="formitems_upload.asp">
: > : Select file:

: > :

: > :
: > :

: > :
: > :
: > : ======================================
: > :
: > :
: > : <%
: > : Set Upload = Server.CreateObject("Persits.Upload")
: > : Upload.SetMaxSize 100000, True
: > : Upload.Save
: > : subdir = Upload.Form("subdir")
: > : Path = "d:\" & subdir
: > : Upload.CreateDirectory Path, True
: > : File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<<
line
: > 13
: > : Response.Write "File saved as " & File.Path & "
"
: > : %>
: > :
: > :
: > : =======================================================
: > : The problem I get is this error:
: > : Microsoft VBScript runtime error '800a01a8'
: > : Object required: ''
: > : /cuploaded1.asp, line 13
: > : which says to me that the process is not getting the path from the
form
: > : before. I understand most of it, but I'm not sure why I'm not getting
: > the
: > : path name. I don't think I've missed any quotes or anything and am
not
: > sure
: > : about the upload.form statement.
: > : Can anyone help me please??
: > : TIA
: >
: > Susie...
: >
: > Did the directory get created?
: >
: > If you put this:
: > Response.Write Path & "\" & File.FileName
: >
: > before this:
: > File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line
13
: >
: > Do you get the intended result?

: Thanks Roland

You're welcome. Sorry to mention but posting inline or at the bottom makes
the conversation easier to follow because we may have to refer back to
earlier posts.

: Yes the directory does get created, but the response.write that you asked
me
: to put in doesn't get displayed.

Hmmm. That's not good.
The directory you get created is d:\UpDir but the Response.Write doesn't
show the directory name.

Change your Response.Write line from:
Response.Write Path & "\" & File.FileName

to:
Response.Write "debug: subdir=" & subdir & "
" & vbCrLf & _
"debug: filename=" & File.FileName & vbCrLf

What is the name of the file you are uploading?

: I simply received the error:
: Microsoft VBScript runtime error '800a01a8'
: Object required: ''
: cuploaded1.asp, line 13
:
: which now looks to me like maybe I'm not getting the filename since the
: directory is created??

Do you remove the directory before you test each time?

: And actually this did start out being ASP/DB related as I am needing a way
: to upload a file, then write the filename, description, size, and a few
: other details to an Access DB. It was suggested that I look at this
: component to achieve this, but I'm having trouble with the upload part of
: it. Can you suggest another forum where this part of the component would
be
: better answered?

Ok, my bad. Nevermind. No reason to move it now.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Re: Best way to upload?

am 26.01.2005 09:16:39 von Roland Hall

You can comment out this line until we get the other part correct.
File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line 13

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Re: Best way to upload?

am 26.01.2005 11:40:44 von McKirahan

"SusieQ" wrote in message
news:#wSxy31AFHA.2552@TK2MSFTNGP09.phx.gbl...
> Thanks all
> I'm trying the documentation for AspUpload using their generic code as is
>
> Input Page:
>
>
>
>

> ACTION="formitems_upload.asp">
> Select file:

>

>
>

>
>
> ======================================
>
>
> <%
> Set Upload = Server.CreateObject("Persits.Upload")
> Upload.SetMaxSize 100000, True
> Upload.Save
> subdir = Upload.Form("subdir")
> Path = "d:\" & subdir
> Upload.CreateDirectory Path, True
> File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line 13
> Response.Write "File saved as " & File.Path & "
"
> %>
>
>
> =======================================================
> The problem I get is this error:
> Microsoft VBScript runtime error '800a01a8'
> Object required: ''
> /cuploaded1.asp, line 13
> which says to me that the process is not getting the path from the form
> before. I understand most of it, but I'm not sure why I'm not getting the
> path name. I don't think I've missed any quotes or anything and am not
sure
> about the upload.form statement.
> Can anyone help me please??
> TIA

Use "File.Path" (not "Path") in

File.SaveAs File.Path & "\" & File.FileName

Re: Best way to upload?

am 26.01.2005 14:10:57 von Roland Hall

"McKirahan" wrote in message news:CfqdnW-6j6LT7mrcRVn-3Q@comcast.com...
: "SusieQ" wrote in message
: news:#wSxy31AFHA.2552@TK2MSFTNGP09.phx.gbl...
: > Thanks all
: > I'm trying the documentation for AspUpload using their generic code as
is
: >
: > Input Page:
: >
: >
: >
: >

: > ACTION="formitems_upload.asp">
: > Select file:

: >

: >
: >

: >
: >
: > ======================================
: >
: >
: > <%
: > Set Upload = Server.CreateObject("Persits.Upload")
: > Upload.SetMaxSize 100000, True
: > Upload.Save
: > subdir = Upload.Form("subdir")
: > Path = "d:\" & subdir
: > Upload.CreateDirectory Path, True
: > File.SaveAs Path & "\" & File.FileName <<<<<<<<<<<<<<<<<<<<<<<<<< line
13
: > Response.Write "File saved as " & File.Path & "
"
: > %>
: >
: >
: > =======================================================
: > The problem I get is this error:
: > Microsoft VBScript runtime error '800a01a8'
: > Object required: ''
: > /cuploaded1.asp, line 13
: > which says to me that the process is not getting the path from the form
: > before. I understand most of it, but I'm not sure why I'm not getting
the
: > path name. I don't think I've missed any quotes or anything and am not
: sure
: > about the upload.form statement.
: > Can anyone help me please??
: > TIA
:
: Use "File.Path" (not "Path") in
:
: File.SaveAs File.Path & "\" & File.FileName
:

File.Path doesn't appear to be set until after File.SaveAs
http://www.aspupload.com/manual_memory.html

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Re: Best way to upload?

am 26.01.2005 17:51:13 von SusieQ

Ok - starting anew here (I slept on it and looked with new eyes this
morning) - as it turns out, when I added

For Each File in Upload.Files
.... do the save thing . . .
Next

It worked just fine.


and after this, I even figured out how to add in the information I needed
into the database -
using their database method.

Thanks everyone for all your help!!!