Right, you need to use the upload component method to get POST data from the form. Also you can't get the thread_ID at the time of the upload cuz it's not assigned until after the post is submitted. I did this on my site and it's not a peace of cake, I wouldn't even do it for $20-$30, this is how I did it:
1. I added a file field at the bottom of the post form.
2. I created a new version of post_message.asp called post_message_attach.asp cuz you can't really use the same one to handle the upload, it would be too complicated since you can't use Request.Form.
3. Then I used javascript so that when there's a file on the file field the form will be send to post_message_attach.asp and change the encoding to multipart/form-data, otherwise it'll go to post_message.asp
4. On the post_message_attach.asp I changed all the Request.Form to objUpload.Form. Then first thing I do after all the authentication is upload the file, that way if something goes wrong you can send the user to the not_posted.asp (also have to mod it to show an error like wrong file size or wrong extension, the javascript checks the extension but it can be fooled, ASP can't be fooled)
5. I stored the upload filename in a new table on the db, just the filename and attachment ID.
6. Added a new field called attachment ID to tblThread and stored the attachment ID there.
7. Moded forum_posts.asp to show a link to the attachment at the bottom of the post.
8. Moded all the files that have to do with posts and topics deletion to delete the attachment.
9. I used the stream object to get the files for download and password protected the upload folder cuz I had problem with people leeching attachments on other sites. Can also be stored outside the webroot. I also added a referer check on the download files (made to files, one for images and one for downloads, the one for images displays the images and the other starts the attachment, they both check referers)
10. Write a script to delete attachments that where partially upload (i allow 2 mb uploads and sometimes they don't upload completely and part of the file stays on the server. I added this to the admin section.
11. Moded the permissions to add options to allow this attachment method separately from the other and even permissions for download, so I can even restrict some users from downloading attachments.
If you want to see it go to
www.uznetworkz.com you will have to sign up, and if you do please send me a PM so I can delete your account.
I would post it as a mod but as you can see I've modded my forum so much that I would have to start it all over again and pretty much each and every file on the forum had to be modified for this.
Edited by fernan82