ASP FileSystemObject Upload.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex

    ASP FileSystemObject Upload.

    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.

    <%

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


    Set DirectoryObject = Server.CreateOb ject("Scripting .FileSystemObje ct")
    Set Upload = Server.CreateOb ject("Persits.U pload")

    If Not DirectoryObject .FolderExists(s trFTProotFolder & "\" &
    upload.form("Re questID") Then
    response.write( "Error: Folder Does Not Exist!")
    Else
    strUploadTo = strFTProotFolde r & "\" & upload.form("Re questID") 'file
    is supposed to be saved here
    Count = Upload.Save(str UploadTo)
    Set file = Upload.Files("f ile1")
    Response.Write( Count & " file uploaded.<br>")
    Response.Write( upload.form("Re questID") & "<br>")
    For Each File in Upload.Files
    Response.Write( File.OriginalFi leName & " (" & 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(str UploadTo) ". 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

    #2
    Re: ASP FileSystemObjec t Upload.

    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(s trFTProotFolder & "\" &
    Session("Reques tID") )
    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("Reques tID") variable
    and use that in the upload routine instead of the Upload.form value
    which is not available until after the upload completes.




    "Alex" <iamalex84@gmai l.com> wrote in message
    news:1149795518 .669694.86530@i 40g2000cwc.goog legroups.com...[color=blue]
    > 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.
    >
    > <%
    >
    > strFTProotFolde r = "c:\web\upload\ share" 'file is saved here
    >
    >
    > Set DirectoryObject = Server.CreateOb ject("Scripting .FileSystemObje ct")
    > Set Upload = Server.CreateOb ject("Persits.U pload")
    >
    > If Not DirectoryObject .FolderExists(s trFTProotFolder & "\" &
    > upload.form("Re questID") Then
    > response.write( "Error: Folder Does Not Exist!")
    > Else
    > strUploadTo = strFTProotFolde r & "\" & upload.form("Re questID") 'file
    > is supposed to be saved here
    > Count = Upload.Save(str UploadTo)
    > Set file = Upload.Files("f ile1")
    > Response.Write( Count & " file uploaded.<br>")
    > Response.Write( upload.form("Re questID") & "<br>")
    > For Each File in Upload.Files
    > Response.Write( File.OriginalFi leName & " (" & 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(str UploadTo) ". 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.
    >[/color]


    Comment

    Working...