Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: create new folders on the fly?

  1. #1
    Join Date
    Dec 2002

    create new folders on the fly?


    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)?

    Last edited by sanjuT; 08-16-2004 at 10:35 AM.

  2. #2
    Join Date
    Jan 2004
    Melbourne, Australia
    FSO has a function named 'CreateFolder()'.
    Dim fso
    fso = Server.CreateObject("Scripting.FileSystemObject")
    Andrew Buntine.

  3. #3
    Join Date
    Dec 2002
    Thanks, but how could I incorporate this into my code?

    I am not sure where to put this in, or how to reference it.

  4. #4
    Join Date
    Nov 2003
    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.)

  5. #5
    Join Date
    Dec 2002

    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:


    automatically create the directory named after the EventID?


    Last edited by sanjuT; 08-16-2004 at 10:35 AM.

  6. #6
    Join Date
    Nov 2003
    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.

  7. #7
    Join Date
    Dec 2002
    Thanks, I'll play around with it and see if i can get it to work.

    If anyone else knows, can u provide some help?


  8. #8
    Join Date
    Nov 2003
    Here's a reference: http://msdn.microsoft.com/library/de...ereference.asp

    MSDN is an excellent resource for MS product documentation.

  9. #9
    Join Date
    Dec 2002
    Once again u have been a great help to me!

  10. #10
    Join Date
    Nov 2003
    Glad to be of help

  11. #11
    Join Date
    Dec 2002
    shouldn't this work? it doesn't create the folder named with the value for EventID.

    objFSO.CreateFolder("C:\webapps\markEvents\UploadedFiles" & EventID)

  12. #12
    Join Date
    Nov 2003
    If nothing else, you're missing a "\" before the EventID.


    objFSO.CreateFolder("C:\webapps\markEvents\UploadedFiles\" & EventID)

  13. #13
    Join Date
    Dec 2002
    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:

    so i would want my new folder to be named '214'

  14. #14
    Join Date
    Nov 2003
    Hmmm... I don't see anything wrong... Try doing a response.write on EventID and see if you get what you expect...

  15. #15
    Join Date
    Dec 2002
    OK, well EventID was not being passed.

    I took out this part from my form tag:


    and the EventID WAS passed.

    now i get this error:

    Cannot call BinaryRead after using Request.Form collection.

    i passed EventID thru a hidden field (from uploadform.asp to uploadexmple.asp):

    <INPUT type="text" ID="Event" NAME="Event" value="<%=EventID%>">

    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.

    Any ideas?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.14297 seconds
  • Memory Usage 2,995KB
  • Queries Executed 13 (?)
More Information
Template Usage (36):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates