Author |
|
nwebster Newbie
Joined: 12 April 2005 Location: United States
Online Status: Offline Posts: 9
|
Posted: 08 September 2005 at 3:11pm | IP Logged
|
|
|
Do you have any sample or example of how to do multiple file uploads on the same page and loaded into different directories? I thought I had seen one before, but can't seem to find it now.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 08 September 2005 at 3:34pm | IP Logged
|
|
|
This sample saves all files into C:\Temp folder. You can easily modify it to save each file into separate folder, such as use variable instead of a constant for DirPath parameter, or build this DirPath dynamically for each file.
The most important thing is that Uploader object keeps all files in memory until you save them. Thus, no temporary files are created, and each file is saved only if it SaveToDisk method was called for that file.
Code:
<% Set Uploader = Server.CreateObject("MailBee.Uploader")
Uploader.ParseRequest Request.BinaryRead(Request.TotalBytes)
If (Uploader.FormElements.Count <> 0) Then
Set File = Uploader.FormFiles(Uploader.FormFiles.Count)
File.SaveToDisk "C:\Temp\", "type the new file name here"
End If %>
|
|
|
Original HTML form which posts data to the page above must have enctype="multipart/form-data" in FORM tag and contain at least one <input type=file> element inside <FORM>...</FORM>.
Regards,
Alex
|
Back to Top |
|
|
nwebster Newbie
Joined: 12 April 2005 Location: United States
Online Status: Offline Posts: 9
|
Posted: 08 September 2005 at 3:41pm | IP Logged
|
|
|
Thanks. Do you know of a way to add a new file input each time a file is uploaded? i.e. if I see one upload option there, press browse and select a file, then it presents a second upload field option, and so on...
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 10 September 2005 at 12:37pm | IP Logged
|
|
|
Mainly it's a question of javascript programming on the client (not server) side.
For example, you can place file upload controls into <TABLE>, and attach onclick handler to <INPUT TYPE=FILE> control. Each time onclick fires, add new row containing new file control (with onlick handler set) to the table.
You may also check if all already existing file controls have not-empty ".value" property to avoid adding new file controls if there is no shortage of empty file upload slots.
Regards,
Alex
|
Back to Top |
|
|