i have a form where there are 2 pages. the 1st is for form data, the 2nd for uploading attachments. For each time a new form is filled out, it gets assigned an EventID (so the info can be looked at later).
I am able to upload files to a folder (UploadedFiles) no problem.
What I need is to be able to create a new folder in UploadedFiles for each new EventID. That way I can associate the attachments to specific Events. I would like the new folders to be named with the EventID (so EventID =44, the folder containing the attachments for it is in \UploadedFiles\44).
The way I have it now, no new folders are created, and all attachments are put into UploadedFiles. So now when I view the attachments (I have a table that displays them) all attachments for all events are listed.
I pass the EventID in the URL in order to display the correct event.
Here is the code that uploads:
Is there a way to add a new folder named with the EventID if it doesn't already exist? if it does, can the attachment be put in it (if it's for the same EventID)?
Before you save to disk, look for the directory. If it's not there, create it. Save to the directory, as it'll now be there. (Of course, it doesn't hurt to watch out for and handle errors.)
again, i am a relative newbie, so i do not know how to even do this correctly, but i understand the logic of it.
so i check if the directory exists. how? test if that directory equals true? i know it would be a loop, so if it doesn't exist, i plug in the fso code?
does the line:
fso.CreateFolder(EventID)
automatically create the directory named after the EventID?
I don't actually do classic ASP anymore, and I don't recall the details on usage of the FSO object, so you'd either need to check the documentation (best idea) or wait for someone who knows to reply.
The logic is:
-If directory doesn't exist
--Create directory
...
-Save to directory
After the "if", the directory will exist (or there was an error), so you can save to it. Logically, there's no difference whether or not it existed before the "if".
If you're saving multiple files to the same directory in a loop, put the "if" before the loop, not inside it.
i saw that and added the "\", but it's not working.
i dimmed a variable, and assigned it a text value (ie "new"). i used the same syntax as above and it DID create the "new" folder, so i assume my prob is with EventID.
it has been dimmed, and is set here:
EventID = request.QueryString ("Event")
this must be where my problem is.
does that line take the value from the URL? for example, my URL would be:
where i set EventID as:
EventID = request.QueryString ("Event")
So now the info goes to uploadexmple.asp, and i attempt to retrieve EventID by:
EventID = request("Event")
the error occurs in another page, upload.asp (a bunch of classes):
biData = Request.BinaryRead(Request.TotalBytes)
I think this problem has to do with the EventID = request("Event") part.
I remember something about not being able to use this if already used, or something like that.
Bookmarks