Forum Moderators: open
<%
Set ObjUpload = Server.CreateObject("UploadProject.UploadClass")
ObjUpload.Flocation="c:\tmp"
'objupload.Flocation= "c:\upload"
objupload.DoUpload
%>
This is simple, are there others codes? and do I need to keep any database information about the attachment filename or its root.
I don't know if this is the solution but how about zipping the files and associating them with the appropriate message. Zip files gives a popup window by default I think when you click on them.
You should therefore have a database field for the url of the files associated with the message, and have link or image with <a href="<%=myRecordset.myFileToDownloadUrl%>">.
This should allow you to link files to your messages.
Leo
Thank you very much for answering, I am so glad that people are very active in this website. I am a beginner in asp, so I might not understand things very well. for the code above
"myFileTodownloadUrl" is the field name in the database used for accessing the location of the file right?
I am not sure, otherwise what does this code means?
And
For example, if I upload a file to a topic, I will browse from my computer
c:\mydoc\filename.txt
After i uploaded the file, the location will be in the server
c:\upload\filname.txt
How do I record the target location and its filename so that it could the database field? When others will download the file, they will download from this target in the server.
"myFileTodownloadUrl" is the field name in the database used for accessing the location of the file right?
yes
How do I record the target location and its filename so that it could the database field?
Are you using a form to 'post' you messages. if so simply add a formfield for your file's url. check out aspin.com or 4GuysFromRolla.com there's great asp tutorials there.
Leo
<FORM ACTION="UploadReceive.asp" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE=FILE NAME="UploadFormName">
<INPUT TYPE="SUBMIT">
</FORM>
add a formfiled is it the
<input type=file name="uploadFormName">?
if i take
Request.Form(uploadFormName) in the UPloadRecieve.asp, it will come out as an url and the filename of the client's computer.(eg. c:\mydocs\text.txt) How do I retrieve the filename? I try to look in some aspin 's script they are in VB and I m not very familiar to that.
I try to use
-----
Dim filelocation
Dim name
filepath = Request.Form(uploadFormName)
Set fs= Server.CreateObject("Scripting.FileSystemObject")
Set myFile=fs.GetFile(filePath)
name = myFile.Name
------
the line filepath normally is
filepath = "c:\test.txt"
How to I get the double quote there. If I put
filepath = "Request.Form(uploadFormName)"
it will be error
And I am not sure this server.CreateObject will get the filename from the client's computer. If not, then
what about Client.CreateObject?
Please suggest something for me. I really want to get this job done. The main problem is getting the filename.
One question now how do you create your posts on your webboard? are you using a form that fills a database? If yes:
If anything doesn't work just post another message here (I am not that good with asp ;) )
Leo
#1 Find the beginning of the file tag name (UploadFormName)
intFileTagStart = InStr(strHeadData, "UploadFormName")
'#2 Find the beginning of the FilePath ('filename=' plus 10 chars)
intPathNameStart = InStr(intFileTagStart, strHeadData, "filename=") + 10
'#3 Find the quote at the end of the file name sent by the user
intFileNameEnd = InStr(intFileTagStart, strHeadData, vbCrLf) - 1
' Check if no file name was sent (exit sub for this example)
If intPathNameStart = intFileNameEnd Then Exit Sub
'#4 Parse the path name
strPathName = Mid(strHeadData, intPathNameStart, intFileNameEnd - intPathNameStart)
'#5 Find the starting position the file name
For intCount = intFileNameEnd To intPathNameStart Step -1
If Mid(strHeadData, intCount, 1) = "\" Then
intFileNameStart = intCount + 1
Exit For
End If
Next
'#6 Now parse the file name
strFileName = Mid(strHeadData, intFileNameStart, intFileNameEnd - intFileNameStart)
In the last one which is no.6 parsing the filename.
It is getting the filename. How do I use this
strFileName in this .cls file to show or use in my .asp page?
This is how the source code call the class's functions, so there should be a way to link the variable strFileNamein the class. Since it is inside the function DoUpload, could i use ObjUpload.DoUpload.strFileName, I can't test it at the server until I am pretty sure about the code :
<%
Set ObjUpload = Server.CreateObject("UploadProject.UploadClass")
ObjUpload.Flocation="c:\tmp"
'ObjUpload.Flocation="c:\"
ObjUpload.DoUpload
%>