|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Conditional uploading with Persits ASPUpload
I'm creating a little image manager and I'm using Persits ASPUpload. I have an UploadButton and DeleteButton which are both submits. Normally I would do:
Code:
If Request.Form("UploadButton") <> "" Then
' perform the upload
Else If Request.Form("DeleteButton") <> "" Then
' perform deletion
End If
...but as some of you may know you can't use Request.Form when using ASPUpload because the form requires have the enctype="multipart/form-data" attribute which makes Request.Form unavailable. It is however possible to access it like: Code:
Dim upload : Set upload = Server.CreateObject("Persits.ASPUpload")
upload.Save("c:\somewhere")
Response.Write(upload.Form("UploadButton")) ' writes the value of UploadButton
...but I want to only perform the upload when the upload button has been clicked. To access upload.Form(...) to check if the button has been clicked you must first call upload.Save, which uploads the files and populates the upload.Form property. This is a strange problem. I'm sure I could get around it by uploading to a temp dir and then copying to the final directory if the upload button has been clicked, or upload them then delete them again if upload button was not clicked, but I shouldn't have to. Anyone got any ideas? I'm probably missing something simple, I hope so. Thanks in advance.
__________________
Kind Regards, John Rebbeck john@interspire.com ICQ# 74637937 |
|
#2
|
|||
|
|||
|
I had a lot of trouble doing something similar a while ago. I wound up relying heavily on this article. Basically you binaryread everything into a variable and then parse that looking for your form fields.
http://msdn.microsoft.com/library/d...tml/asp0900.asp I've found this sort of thing to be a breeze in .NET, so if that's an option I'd go for it. |
|
#3
|
|||
|
|||
|
The way I handle all my self posting forms is a quick and easy solution to part of your problem. Rather than checking the value of a button to see if it has been posted, append a query string "Action" variable to your form action. You can then access the query string as usual.
Ex: action="upload.asp?Action=DoUpload" Since this will only work with a single method form, I suggest you do some JS work on the form page to manage the two button approach. You could change your buttons to "button" rather than "submit" type, then have them run some Javscript to set the appropriate action on the upload form. You can't just use hidden upload forms because scripting is blocked on file fieds. Last edited by wes : July 18th, 2003 at 02:24 PM. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Conditional uploading with Persits ASPUpload |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|