|
Hi all,
I have a posto below with a problem in the download.asp file.
I have figured it out and here is the corrected download.asp file:
******************************************************************
<%
if getData("select * from doc_warhouse where doc_name <> '' and doc_id='" & request("doc_id") & "'",rs) > 0 then
Response.ContentType = rs("doc_type")
Response.AddHeader "Content-Disposition", "filename=" & rs("doc_name")
Response.BinaryWrite rs("doc_data")
Else
%>
File not found in the database.
<%
End If
%>
***********************************************************************
Hope this helps,
Nelson Ribeiro.
|
|
|
|
|
I found your class very useful and have added a GetText() function for ease of use with Text processing.
<br />
Public Function GetText()<br />
if m_strContentType = "text/plain" Then<br />
Dim lngLoop, strOut<br />
For lngLoop = 1 to LenB(m_Blob)<br />
strOut = strOut & Chr(AscB(MidB(m_Blob, lngLoop, 1)))<br />
Next<br />
GetText = strOut<br />
else<br />
GetText = "Wrong Content type! (content type: " & m_strConectType & ") (required type: text/plain)"<br />
End if<br />
End Function<br />
Thank you,
Ryan
.:~Analyst Developer~:.
|
|
|
|
|
Hi Ryan,
what does this funtion do? In what asp file should I put it and where to I make the calls of this function?
thanks in adv,
nelson
|
|
|
|
|
Hi Nelson,
I created this function (added to the bottom of the vbsupload.asp (that's the include), inside the class underneath the save subroutine) to simply extract the text from the uploaded file(s), but it first checks to make sure that the uploaded files are of 'text'.
I found it useful as my user(s) will be uploading xml (text) files which I wanted to process on-the-fly, this works for me.
Ryan
.:~Analyst Developer~:.
|
|
|
|
|
Nelson,
You call GetText() from within your 'main' asp page, the same page that has the <.. include of "vbsupload.asp"...>.
Example: myVariable = myObject.Files.Item(1).GetText()
Presuming in the above example that 'myObject' is set to your class.
Ryan
.:~Analyst Developer~:.
|
|
|
|
|
hi all,
first of all, I would like to give credit to the guy that wrote these files.
The code is excelent (althought I don´t understand much of ASP I can recognize a good piece of code when I see it).
Because I am a newbie to ASP, I really need some help to understand and correct the behaviour I am getting from these pages.
Here are a couple of things:
1) the download.asp page doesn´t work for me, I mean I get an error in the following SQL statement:
if getData("select * from doc_warhouse where doc_name <> '' and doc_id=" & request("doc_id"),rs) > 0 then
Response.ContentType = rs("doc_type")
....
I have changed it to:
if getData("select * from doc_warhouse where doc_name <> ''",rs) > 0 then (...)
The problem is that I don´t know if the result is the expected behaviour or not.
2) On the other hand, everytime i try to upload a file to the database, I get a window like the ones that appear when we are trying to download a file, althought the file is recorded to the database...a bit strange.
3) How can I retrieve a specific file from the database and show it the browser? I don´t know why but in my case it tries do download/view always the first file in the database.
I could really use some help on this....
Thanks in advance,
Nelson Ribeiro.
|
|
|
|
|
If you had enabled "Client Side debugging" under IIS, you should get a :
"Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument
vbsupload.asp, line 270"
On the current file version the error is locate on line 236 :"objFSOFile.Write Chr(AscB(MidB(m_Blob, lngLoop, 1)))"
So I suggest to add an "On errror resume Next" at the beginning of the sub Save
|
|
|
|
|
see the following article:
http://www.codeproject.com/aspnet/multiuploads.asp
the lines to save the file are:
string fn = System.IO.Path.GetFileName(HIF.PostedFile.FileName);
HIF.PostedFile.SaveAs(baseLocation + fn);
2 lines compared to i don't know how many in VBS.
|
|
|
|
|
yes but the subject is : File Upload WITHOUT COM object
un aspnet you use the framework upload object...
|
|
|
|
|
i read the title, thank you.
usually the hindrance for uploading files in classic asp, is that the components are either too expensive, or the server is a shared server and there's no way to upload a custom component. with .net, the functionality is already in the framework. you don't have to write a class in vbscript to perform the upload. it's already there for you.
just another option, that's it.
|
|
|
|
|
Hi, i've found the class works very good to save file
how can i access to the name property of a form element ?
I thought it can be done using
objUpload.Form.Item(n).Name
but it doesn't work
i see the name is stored into the form collection but i can't retrieve it
<br />
Else 'It is a form element<br />
.....<br />
'Add the element to the collection<br />
Response.Write(strName)<br />
m_objForm.Add strName, strValue<br />
please tell me what's wrong...
thanks
Giuliano.
|
|
|
|
|
Hi, i've resolve my question adding another class
<br />
Class vbsField<br />
'=============================================================='<br />
' This class is used as a container for a field sent via '<br />
' an http multipart/form-data post. '<br />
'=============================================================='<br />
Private m_strName<br />
Private m_Value<br />
<br />
Public Property Get Name() : Name = m_strName : End Property<br />
Public Property Let Name(vIn) : m_strName = vIn : End Property<br />
Public Property Get Value() : Value = m_Value : End Property<br />
Public Property Let Value(vIn) : m_Value = vIn : End Property<br />
<br />
End Class<br />
and make some changes to the parser sub
<br />
Private Sub ParseRequest()<br />
........<br />
Else 'It is a form element<br />
<br />
Get the value of the form element<br />
lngPosTmp = InStrB(lngPosTmp, strBRequest, UStr2BStr(chr(13)))<br />
lngPosBeg = lngPosTmp + 4<br />
lngPosEnd = InStrB(lngPosBeg, strBRequest, strBBoundary) - 2<br />
VbTab & strValue = BStr2UStr(MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg))<br />
'Create the Field object, and add it to the Form collection<br />
Set objField = New vbsField<br />
ObjField.Name = strName<br />
ObjField.Value = strValue<br />
'Add the element to the collection<br />
m_objForm.Add strName, objField<br />
<br />
End If<br />
now i can access to name property using
objUpload.Form.Item(x).Name
where x is an integer or the field name.
in example u can use
<br />
For lngLoop = 0 to objUpload.Form.Count - 1<br />
<br />
Response.Write(objUpload.Form.Item(lngLoop).Name & " - " & objUpload.Form.Item(lngLoop).Value)<br />
<br />
Next<br />
or to access directly to a filed:
<br />
Response.Write(objUpload.Form.Item("My_Field").Name & " - " & objUpload.Form.Item("My_Field").Value)<br />
Thanks to all.
Giuliano
|
|
|
|
|
I use vbsUpload.asp to upload file to database ,when the image file size is in ODD,there be always 1 byte lost when get images from database so it can't normally be shown,so I correct it from Line 93,the total size must PLUS 1,
'Get the Content
lngPosBeg = lngPosEnd + 4
lngPosEnd = InStrB(lngPosBeg, strBRequest, strBBoundary) - 2
strBContent = MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg+1)
that is last line,after that i can catch image from database with no error,please check it.
|
|
|
|
|
Hi,
I want to get the name of each field in the form collection. So I tried the following code:
1: for i = 0 to objUpload.Form.count - 1
2: response.write "i: " & i & " "
3: response.write "Value: " & objUpload.Form.Item(i) & " "
4: response.write "Name: " & objUpload.Form.Item(i).name & " "
5: next
I get an error at line 4 saying:
<<
Runtime error in Microsoft VBScript- error'800a01a8'
Object needed: '[string: "emp"]'
/sendMail.asp, line 15
>>
(translated the error messages as good as i can)
But this code gives me the value for i in the form collection (that was emp) but not the name. Now I wonder where is the bug in my Head or in the vbsUpload.asp.
Does Anybody has a solution for my Problem
(using w2k Prof)
Thanks in advance
Alex
|
|
|
|
|
I'm trying to upload a two files and send the files as attachement.
The code below pretty simple to upload the files, but doesn't work for me ...
any clue is appreciated
-Pankaj
<%@ Language=VBScript %>
>
Your File:
<%
Dim objUpload, lngLoop
If Request.TotalBytes > 0 Then
Set objUpload = New vbsUpload
For lngLoop = 0 to objUpload.Files.Count - 1
'If accessing this page annonymously,
'the internet guest account must have
'write permission to the path below.
objUpload.Files.Item(lngLoop).Save "c:\Newupload\"
Response.Write "File Uploaded"
Next
End if
%>
|
|
|
|
|
I can't seem to get the objUpload.Files.Count to ever go above 0. I have tried this form on multiple servers and get nada. Any suggestions or help would be much appreciated.
|
|
|
|
|
in process_files.asp,you just add more into the form,that is.
roger nie
|
|
|
|
|
Hi Roger,
I tried to email this to you, but your disk quota was full, so I decided to post it here even though it doesn't have anything to do with the previous post. Sorry to take so long getting back to you - don't check my hotmail account too much these days.
If I understand you correctly the problem you are running into is when someone submits the form without entering in a file. I got around this through adding in a section of error checking ot the process pages. I've been using the component for a while, so I've modified it quite a bit. Here is a snippet of code to check 1) if there is a file object, 2) if that file has a name, and 3) if that file is of a certain type. If it fails any of these criteria is sets a session vaiable with an error message that can be displayed on the original upload page, then redirects back to that page.
if not isobject(objUpload.Files.Item(0)) then
strErrors = strErrors & "No document selected or document does not exist."
session("strErrors") = strErrors
response.redirect("docUpload.asp")
else
'strErrors = ""
if objUpload.Files.Item(0).FileName = "" then
strErrors = strErrors & "You must select a document."
end if
if instr(lcase(objUpload.Files.Item(0).FileName),".txt") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".zip") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".eps") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".psd") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".gif") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".jpg") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".ppt") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".doc") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".dot") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".rtf") = 0 and instr(lcase(objUpload.Files.Item(0).FileName),".pdf") = 0 then
strErrors = strErrors & "You are limited to uploading documents of the following types: eps, zip, dot, jpg, gif, ppt, doc, pdf, psd, txt, and rtf. If your document is of that type and you are still encountering problems, please check to make sure that the document name has the correct suffix on the end."
end if
session("strErrors") = strErrors
response.redirect("docUpload.asp")
end if
Then, back on the upload page you can have a snippet of code that checks if the session("srtErrors") is set, and if so, displays the error and resets the session to "". You can change any of the document types or add in any other error check you need and just make sure to set the session and do the redirect.
Hope this helps!
--Paul
|
|
|
|
|
Sorry, the <li> tags got parsed. The strErrors variable should look like:
strErrors = "<li>Error message<li>"
--Paul
|
|
|
|
|
|
|
Hi,
how to get the values from the a select box that allows multiple values. If i use request.form("mySelBox") if give back something like e.g.: 1,2,3,4. But if i use objUpload.Form.Item("mySelBox") it gave back just the last value. Is there any chance to get the other values.
Thanks for your help
ALex
|
|
|
|
|
I have the same problem and it seems that nobody has solved (or posted) the answer to this question. If anybody has ideas, please post...
|
|
|
|
|
I'm having the same problem and would appreciate some help
|
|
|
|
|
Hey guys!
I don't know if that is recent or not.
If you have a select, with multiple values, you can access all of its entries with the option array.
When accessing all elements of the option array, you look for the selected entry, which tells you if the given entry is selected or not.
That's the way I do it.
Hope this helps in this case.
Nice regards
Werner
|
|
|
|
|