PDA

View Full Version : upload files


ahmedsoliman
04-14-2003, 01:58 PM
when using upload opject, is it must to use for next to get the file or files.

the same with any item in my form beside the files, can i requst each item alone without for next.

i have the following code supported from my host:


Set Upload = Server.CreateObject ("Persits.Upload.1")

' Upload files


Upload.OverwriteFiles = False ' Generate unique names

Upload.SetMaxSize 1048576 ' Truncate files above 1MB

Upload.SaveVirtual "/data" ' Save to data directory
' Process all files received


For Each File in Upload.Files

' Save in the database as blob

File.ToDatabase "DSN=userid.dsn_name;UID=user_id;PWD=account_Password;",_
"insert into uploadTable (id, FilePath, image)values (12, '" & File.Path & "',?)"




Next

For Each Item in Upload.Form

If Item.Name = "Category" Then

Response.Write Item.Value & "<BR>"

End If

Next

Set Upload = Nothing

raf
04-14-2003, 03:02 PM
Not sure i understood that.

For each item in request.form
next

will run the command for all fromallements

If you only need the value from one formelement or just want to run some commands for one variable, use

request.form("variablename")


The for each next loop is better if you need to execute some commands on multiple variables with the same function.

If you have 10 filename-fields on your form, then its better to use the for each next loop (shorter code, easier to update, can expand automatically etc). If you only have one filenamefield, you can just drop the
"For Each Item in Upload.Form " an "Next" lines and replace the "Item.Value" with the variablename.

oracleguy
04-14-2003, 07:36 PM
<edit>My bad; I could of swore it was in the HTML forum this morning</edit>

dominicall
04-14-2003, 07:46 PM
Ummmmm - it is in the ASP forum

????

dominicall

ahmedsoliman
04-14-2003, 07:54 PM
i think i know what my question belongs to, and i know what this forum dicuss.
thanks raf but any item in the form taked as binary and (rquest) dosen't work.
any help??:)

dominicall
04-14-2003, 07:59 PM
I use ASPUpload a lot so could probably help....

just need you to put your query in context a bit more....

What's the objective of the form - to upload images to the database and then assign a category to each image???

dominicall

glenngv
04-15-2003, 09:36 AM
just an educated guess since i haven't used the Persits Upload component.

I believe Form is a collection since it was used like this:

For Each Item in Upload.Form
'code here
next

knowing that, you can get the value of an item like this:

Upload.Form("itemname")