ASP FileSystemObject Upload.

Discussion in 'ASP General' started by Alex, Jun 8, 2006.

  1. Alex

    Alex Guest

    I am having issues with a script to upload files from a client to a
    webserver. The problem is not with the actual upload but with where it
    uploads. The whole process is supposed to create a folder (it does)
    then upload the file to that folder and this is where the problem comes
    in. The file is written to the parent directory, not the directory
    that was created for this user. Following is the code.

    <%

    strFTProotFolder = "c:\web\upload\share" 'file is saved here


    Set DirectoryObject = Server.CreateObject("Scripting.FileSystemObject")
    Set Upload = Server.CreateObject("Persits.Upload")

    If Not DirectoryObject.FolderExists(strFTProotFolder & "\" &
    upload.form("RequestID") Then
    response.write("Error: Folder Does Not Exist!")
    Else
    strUploadTo = strFTProotFolder & "\" & upload.form("RequestID") 'file
    is supposed to be saved here
    Count = Upload.Save(strUploadTo)
    Set file = Upload.Files("file1")
    Response.Write(Count & " file uploaded.<br>")
    Response.Write(upload.form("RequestID") & "<br>")
    For Each File in Upload.Files
    Response.Write(File.OriginalFileName & " (" & File.Size &"
    bytes)<br>")
    Next

    End If

    %>

    I think the problem has to do with the 'RequestID' variable. It is
    empty until after this line " Count = Upload.Save(strUploadTo) ". I
    don't understand why it isn't populated until then. I had it print the
    value of said variable every other line to see what it's value was
    through the process.
    Alex, Jun 8, 2006
    #1
    1. Advertising

  2. I would think you would create the folder when creating
    the client record instead of during an upload routine

    However you said the folder is created during the process
    and I see nothing that creates a folder in the syntax;
    A line like
    Set ClientFolder = DirectoryObject.CreateFolder(strFTProotFolder & "\" &
    Session("RequestID") )
    unless there is more code somewhere.

    I would not rely on a method that has to wait until it is finished
    especially when you are relying on it to create other things.
    when the user logs on create a session("RequestID") variable
    and use that in the upload routine instead of the Upload.form value
    which is not available until after the upload completes.




    "Alex" <> wrote in message
    news:...
    > I am having issues with a script to upload files from a client to a
    > webserver. The problem is not with the actual upload but with where it
    > uploads. The whole process is supposed to create a folder (it does)
    > then upload the file to that folder and this is where the problem comes
    > in. The file is written to the parent directory, not the directory
    > that was created for this user. Following is the code.
    >
    > <%
    >
    > strFTProotFolder = "c:\web\upload\share" 'file is saved here
    >
    >
    > Set DirectoryObject = Server.CreateObject("Scripting.FileSystemObject")
    > Set Upload = Server.CreateObject("Persits.Upload")
    >
    > If Not DirectoryObject.FolderExists(strFTProotFolder & "\" &
    > upload.form("RequestID") Then
    > response.write("Error: Folder Does Not Exist!")
    > Else
    > strUploadTo = strFTProotFolder & "\" & upload.form("RequestID") 'file
    > is supposed to be saved here
    > Count = Upload.Save(strUploadTo)
    > Set file = Upload.Files("file1")
    > Response.Write(Count & " file uploaded.<br>")
    > Response.Write(upload.form("RequestID") & "<br>")
    > For Each File in Upload.Files
    > Response.Write(File.OriginalFileName & " (" & File.Size &"
    > bytes)<br>")
    > Next
    >
    > End If
    >
    > %>
    >
    > I think the problem has to do with the 'RequestID' variable. It is
    > empty until after this line " Count = Upload.Save(strUploadTo) ". I
    > don't understand why it isn't populated until then. I had it print the
    > value of said variable every other line to see what it's value was
    > through the process.
    >
    Michael Kujawa, Jun 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pedro Bautista
    Replies:
    0
    Views:
    521
    Pedro Bautista
    Aug 29, 2003
  2. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    FileSystemObject Question

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Nov 22, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    2,691
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 22, 2004
  3. =?Utf-8?B?a2VybWl0?=

    Script w/ FileSystemObject, error creating object

    =?Utf-8?B?a2VybWl0?=, Apr 22, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    5,163
    =?Utf-8?B?a2VybWl0?=
    Apr 24, 2005
  4. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,421
    Bruce Barker
    Aug 3, 2005
  5. Jeff

    FileSystemObject and asp

    Jeff, Feb 28, 2006, in forum: ASP General
    Replies:
    5
    Views:
    116
Loading...

Share This Page