File upload mod - help needed
Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=6554
Printed Date: 03 April 2026 at 5:57pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: File upload mod - help needed
Posted By: svpworld
Subject: File upload mod - help needed
Date Posted: 19 October 2003 at 10:25am
|
I hope this is the right place to post this, if not please move it.
I am in the process of modifying the upload_files.asp to log the files uploaded in a separate table, including filename, topic_ID, Thread_ID, plus 2 other choices specific to my forum (namely type of file and file source).
For the latter I have added two list boxes using <option>....</option> which are populated from a table in the sql db.
My first question is how to pass the chosen values from the list boxes included in my form back to the script, given that it reposts and uses the post rather than get option. I am a novice at ASP so finding this a bit tricky to work out, despite it may be easy. I've tried reading the variables using request.form but couldnt get it working.
Second question is can I determine the Topic_ID and Thread_ID at this stage during file upload, or do i have to do this after the file link is added to the post (so I know where the file was added)?
Thanks!
Simon
|
Replies:
Posted By: svpworld
Date Posted: 19 October 2003 at 1:17pm
|
Further to my last post, the problem appears to be that using Persits ASPupload the function file upload generates an error if I attempt to request the variables from the lists in my form first. If I try and request them after the file upload they are no longer available.
For example I placed this at the beginning of the upload_files.asp page so when it was reposted it would get the values of my drop down lists on the file upload form viz ;
Dim SVPname,SVPsource SVPname = Request.Form("FileTypeID") SVPsource= Request.Form("FileSourceID")
In doing so I presume it affects the filename passed to the upload function? Hope someone follows what I mean!
Simon
|
Posted By: Str8Dog
Date Posted: 19 October 2003 at 2:04pm
svpworld, seeing as how you have a limited knowledge of ASP, your best bet may be to offer $20-$30 on the board to anyone who can make the mod for you.
There are several people on the board who could do this mod for ya in short order.
------------- http://www.str8dog.com/ - [IMG - http://www.str8dog.com/images/str8dog.gif -
I wasn't born with enough middle fingers.
|
Posted By: svpworld
Date Posted: 19 October 2003 at 2:17pm
|
I appreciate that Str8Dog, but the essence of doing this is for me to learn. I'll try another route, and keep the file upload dialog separate from my own form.
Regards Simon
|
Posted By: Str8Dog
Date Posted: 19 October 2003 at 2:28pm
If you are interested in learning asp, I highly suggest the following books:
Beginning ASP 3.0
Beginning ASP Databases
These two books will cover everything you need to know to modify the forums. They are put out by Wrox press and should be avalible from Amazon for around $10 used.
------------- http://www.str8dog.com/ - [IMG - http://www.str8dog.com/images/str8dog.gif -
I wasn't born with enough middle fingers.
|
Posted By: svpworld
Date Posted: 19 October 2003 at 2:33pm
|
Thanks, I'll check those out! I'm ok with most other aspects of ASP including DB accessing and control, its just forms sometimes throw up unexpected surprises! I thought it would be simple enough to request.form and obtain any objects within the form, but it seems the filename field works a bit differently to what I expected.
Regards Simon
|
Posted By: Tegwin
Date Posted: 19 October 2003 at 2:57pm
Str8Dog wrote:
If you are interested in learning asp, I highly suggest the following books:
Beginning ASP 3.0
Beginning ASP Databases
These two books will cover everything you need to know to modify
the forums. They are put out by Wrox press and should be avalible from
Amazon for around $10 used. |
I agree with Str8Dog these two books are really good. I have bought
them both recently and i am halfway through the Beginning ASP book.
Well worth the money
------------- If you dont want my peaches, dont shake my tree
|
Posted By: svpworld
Date Posted: 19 October 2003 at 3:01pm
|
Cheers guys, I've got them both on order as we speak!
(but I'd still like to know if theres an easy way to read these darn listboxes in the upload form! )
Simon
|
Posted By: Str8Dog
Date Posted: 19 October 2003 at 5:09pm
Simon,
You need to verify the select element is named in your html. Something like
<select name="myList">
If the form is submitted as POST, you can access the values like so:
Request("myList")
If the form is submitted as GET, you can access the values like so:
Request.QueryString("myList")
------------- http://www.str8dog.com/ - [IMG - http://www.str8dog.com/images/str8dog.gif -
I wasn't born with enough middle fingers.
|
Posted By: svpworld
Date Posted: 19 October 2003 at 5:26pm
|
I did try this as you say, but the method aspupload (persits) works, it is not possible to request the form object variables in this way due to the multipart/form-data attribute in the upload form. However looking through persits application data it does offer two collections of its own, one of which is upload.form... I think I might be able to use this from the upload function somehow to get the variables... Anyway I'll try!
Thanks for your help.
Simon
|
Posted By: fernan82
Date Posted: 19 October 2003 at 9:22pm
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 http://www.uznetworkz.com - 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.
------------- FeRnAN
http://www.danasoft.com/">
|
Posted By: svpworld
Date Posted: 20 October 2003 at 6:24am
|
Thanks Fernan, you have given me some useful guidance! I took a look at your site, had some problems though getting back in once I registered and I found your forum very slow.. is it access?
I probably dont need to implement the file upload into the post form as you have, my idea was to use the existing upload pop up form. I want to add a couple of drop down list menus on the form so users can specify what they upload and then read the values. I'll use the upoad component as you have confirmed, I assume I'll need to do this within the function somewhere? Regarding the thread number, perhaps I can add something once the message is added, though I like the way you add the paper clip icon and track if the post is deleted to remove the file...
Thanks!
Simon
|
Posted By: fernan82
Date Posted: 20 October 2003 at 7:24am
No prob., it's sql, probably something was going on when you visited as the site is known to be pretty fast unless I'm doing maintenance or something... Yes, you'll have to do it within the function cuz once you close the upload object you can't get the form anymore..., I just got the email, you didn't say if you get any errors or what the problem was but your account is fine, there's a link to resend the pwd on the main page, you can try that and make sure you didn't blocked my cookies.
------------- FeRnAN
http://www.danasoft.com/">
|
Posted By: svpworld
Date Posted: 21 October 2003 at 9:14am
|
Hi again Fernan,
I do like your file upload mod. Although I can probably manage most of this, I'm not too hot on Javascript... how did you manage to check if there is a filename in the file input box before posting the message? Another thing I like about this mod is that is restricts users to uploading just one file per post. Ideally I want to display the attachments under each post from the show posts page, rather than just have url's in the messages (which can be deleted by the user too easily when editing their messages!)... Any more tips would be really appreciated!
Kindest regards Simon
|
|