Trouble with Request.Form Plus Upload

Discussion in 'ASP General' started by Sean Dotson, May 5, 2004.

  1. Sean Dotson

    Sean Dotson Guest

    I have a form that passes variables to an asp file and then uploads a file.
    For some reason the request.form is not getting the info from the form.
    It's returning blanks. Any insight would be appreciated....

    Here is the asp file

    <HTML>
    <HEAD>
    <TITLE>File Upload Results</TITLE>

    <BODY>
    <font color=#000000><b>Files Uploaded Status:</b></font><br><br>

    <%

    Set Upload = server.createObject("Chili.Upload.1")

    Upload.AllowOverwrite = True ' Generate unique names
    'Upload.SizeLimit = 150000 ' Truncate files above 50KB
    On Error Resume Next

    MyArray = Split(Upload.SourceFileName, "\")
    FName = MyArray(UBound(MyArray))

    If Upload.SourceFileExtension = ".pdf" or Upload.SourceFileExtension =
    ".zip" Then

    If Upload.FileSize< 3000000 Then

    UpldAllowed=True

    Else
    UpldAllowed=False

    End If

    Else

    UpldAllowed=False

    End If

    If Upload.SourceFileExtension = ".gif" or Upload.SourceFileExtension or
    ".jpg" or Upload.SourceFileExtension or ".png" Then

    If Upload.FileSize< 150000 Then

    UpldAllowed=True

    Else
    UpldAllowed=False

    End If

    Else

    UpldAllowed=False

    End If

    If UpldAllowed=False Then
    Response.Write "<font color=red><b>Your file is either of an disallowed
    type or is too large. Please <a href=upload.asp>try
    again</a></b></font><br>"
    Else
    Upload.SaveToFile(Server.mapPath("/") & "/" & "/iparttest/upload/" & FName)
    Response.Write "<font color=#000000><b>File: </b></font>" &
    Upload.SourceFileName & " <font color=#009900><b>--Size:" & Upload.FileSize
    &" Bytes -- </b></font> <a target=_blank
    href=http://www.sdotson.com/iparttest/upload/" & FName & ">Click to
    Test</a><br>"
    Response.Write "<br>Copy and paste the following to use your image/file in
    the forum:<br><br>"

    If Upload.SourceFileExtension = ".pdf" or Upload.SourceFileExtension =
    ".zip" then
    Response.Write "<b><font
    color=red>http://www.sdotson.com/iparttest/upload/" & FName & "</b></font>"
    Else
    Response.Write "<b><font
    color=red>http://www.sdotson.com/iparttest/upload/" & FName &
    "</b></font>"
    End If

    End If

    Upload.Close

    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open
    "driver={MySQL};server=localhost;database=username","username","password"

    response.write "stuff"
    response.write "Description="
    response.write (request.form("description"))

    set the variables
    strImageURL = ""
    strFilename = FName
    strDescription = request.form("description")
    strAuthor = request.form("author")
    strCategory = request.form("category")
    strIsVerified = "False"
    strUpdateDate = Date

    sql = "INSERT INTO iparts
    (imageurl,filename,description,author,category,isverified,updatedate) VALUES
    ('" & strImageURL & "','" & strFilename & "','" & strDescription & "','" &
    strAuthor & "','" & strCategory & "','" & strIsVerified & "','" &
    strUpdateDate & "')"
    Conn.Execute(sql)
    Conn.Close

    %>

    </BODY>
    </HTML>


    _____________________________________________


    and here is the form:

    <html>


    <FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="addnewipart.asp">

    <table border="0">
    <tr>
    <td>iPart to Upload:</td>
    <td><INPUT TYPE="FILE" NAME="FILE1"></td>
    </tr>
    <tr>
    <td>Your Name:</td>
    <td><input type="text" name="author" size="50"></td>
    </tr>
    <tr>
    <td>Description:</td>
    <td><input type="text" name="description" size="50"></td>
    </tr>
    <tr>
    <td>Select a Category - <a href="categoryhelp.html">Help</a></td>
    <td> <SELECT NAME="category">
    <OPTION value="hydraulics">Hydraulics
    <OPTION value="pneumatics">Pneumatics
    <OPTION value="fasteners">Fasteners
    <OPTION value="hardware">Hardware
    <OPTION value="powertransmission">Power Transmission
    <OPTION value="fasteners">Fasteners
    <OPTION value="fasteners">Fasteners
    </SELECT>
    </td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" name="submit" value="Upload iPart"></td>
    </tr>
    </table>

    </form>

    </html>



    --
    Sean Dotson, PE
    Autodesk Inventor Certified Expert
    http://www.sdotson.com
    http://www.sdotson.com/forums/
    Check the Inventor FAQ for most common questions
    www.sdotson.com/faq.html
    -----------------------------------------------------------------------
    Sean Dotson, May 5, 2004
    #1
    1. Advertising

  2. Sean Dotson

    TomB Guest

    I'm not familiar with Chili.Upload, but I assume it's the same as other
    uploaders.

    Once you access the objects form objects, Request.Form will no longer be
    available. Take a look at the Chili.Upload docs' It'll likely have it's own
    way of accessing the other form items. Something
    like....Upload.Form("description") I would suspect.

    TomB

    "Sean Dotson" <sean dotson at comcast dot net> wrote in message
    news:...
    > I have a form that passes variables to an asp file and then uploads a

    file.
    > For some reason the request.form is not getting the info from the form.
    > It's returning blanks. Any insight would be appreciated....
    >
    > Here is the asp file
    >
    > <HTML>
    > <HEAD>
    > <TITLE>File Upload Results</TITLE>
    >
    > <BODY>
    > <font color=#000000><b>Files Uploaded Status:</b></font><br><br>
    >
    > <%
    >
    > Set Upload = server.createObject("Chili.Upload.1")
    >
    > Upload.AllowOverwrite = True ' Generate unique names
    > 'Upload.SizeLimit = 150000 ' Truncate files above 50KB
    > On Error Resume Next
    >
    > MyArray = Split(Upload.SourceFileName, "\")
    > FName = MyArray(UBound(MyArray))
    >
    > If Upload.SourceFileExtension = ".pdf" or Upload.SourceFileExtension =
    > ".zip" Then
    >
    > If Upload.FileSize< 3000000 Then
    >
    > UpldAllowed=True
    >
    > Else
    > UpldAllowed=False
    >
    > End If
    >
    > Else
    >
    > UpldAllowed=False
    >
    > End If
    >
    > If Upload.SourceFileExtension = ".gif" or Upload.SourceFileExtension or
    > ".jpg" or Upload.SourceFileExtension or ".png" Then
    >
    > If Upload.FileSize< 150000 Then
    >
    > UpldAllowed=True
    >
    > Else
    > UpldAllowed=False
    >
    > End If
    >
    > Else
    >
    > UpldAllowed=False
    >
    > End If
    >
    > If UpldAllowed=False Then
    > Response.Write "<font color=red><b>Your file is either of an disallowed
    > type or is too large. Please <a href=upload.asp>try
    > again</a></b></font><br>"
    > Else
    > Upload.SaveToFile(Server.mapPath("/") & "/" & "/iparttest/upload/" &

    FName)
    > Response.Write "<font color=#000000><b>File: </b></font>" &
    > Upload.SourceFileName & " <font color=#009900><b>--Size:" &

    Upload.FileSize
    > &" Bytes -- </b></font> <a target=_blank
    > href=http://www.sdotson.com/iparttest/upload/" & FName & ">Click to
    > Test</a><br>"
    > Response.Write "<br>Copy and paste the following to use your image/file

    in
    > the forum:<br><br>"
    >
    > If Upload.SourceFileExtension = ".pdf" or Upload.SourceFileExtension =
    > ".zip" then
    > Response.Write "<b><font
    > color=red>http://www.sdotson.com/iparttest/upload/" & FName &

    "</b></font>"
    > Else
    > Response.Write "<b><font
    > color=red>http://www.sdotson.com/iparttest/upload/" & FName &
    > "</b></font>"
    > End If
    >
    > End If
    >
    > Upload.Close
    >
    > Set Conn = Server.CreateObject("ADODB.Connection")
    > Conn.Open
    > "driver={MySQL};server=localhost;database=username","username","password"
    >
    > response.write "stuff"
    > response.write "Description="
    > response.write (request.form("description"))
    >
    > set the variables
    > strImageURL = ""
    > strFilename = FName
    > strDescription = request.form("description")
    > strAuthor = request.form("author")
    > strCategory = request.form("category")
    > strIsVerified = "False"
    > strUpdateDate = Date
    >
    > sql = "INSERT INTO iparts
    > (imageurl,filename,description,author,category,isverified,updatedate)

    VALUES
    > ('" & strImageURL & "','" & strFilename & "','" & strDescription & "','" &
    > strAuthor & "','" & strCategory & "','" & strIsVerified & "','" &
    > strUpdateDate & "')"
    > Conn.Execute(sql)
    > Conn.Close
    >
    > %>
    >
    > </BODY>
    > </HTML>
    >
    >
    > _____________________________________________
    >
    >
    > and here is the form:
    >
    > <html>
    >
    >
    > <FORM METHOD="POST" ENCTYPE="multipart/form-data"

    ACTION="addnewipart.asp">
    >
    > <table border="0">
    > <tr>
    > <td>iPart to Upload:</td>
    > <td><INPUT TYPE="FILE" NAME="FILE1"></td>
    > </tr>
    > <tr>
    > <td>Your Name:</td>
    > <td><input type="text" name="author" size="50"></td>
    > </tr>
    > <tr>
    > <td>Description:</td>
    > <td><input type="text" name="description" size="50"></td>
    > </tr>
    > <tr>
    > <td>Select a Category - <a href="categoryhelp.html">Help</a></td>
    > <td> <SELECT NAME="category">
    > <OPTION value="hydraulics">Hydraulics
    > <OPTION value="pneumatics">Pneumatics
    > <OPTION value="fasteners">Fasteners
    > <OPTION value="hardware">Hardware
    > <OPTION value="powertransmission">Power Transmission
    > <OPTION value="fasteners">Fasteners
    > <OPTION value="fasteners">Fasteners
    > </SELECT>
    > </td>
    > </tr>
    > <tr>
    > <td></td>
    > <td><input type="submit" name="submit" value="Upload iPart"></td>
    > </tr>
    > </table>
    >
    > </form>
    >
    > </html>
    >
    >
    >
    > --
    > Sean Dotson, PE
    > Autodesk Inventor Certified Expert
    > http://www.sdotson.com
    > http://www.sdotson.com/forums/
    > Check the Inventor FAQ for most common questions
    > www.sdotson.com/faq.html
    > -----------------------------------------------------------------------
    >
    >
    TomB, May 5, 2004
    #2
    1. Advertising

  3. Sean Dotson

    Sean Dotson Guest

    That was it. Thanks. Too bad my host is running Sun ASP v 3.0 which
    doesn't support this. Only V4.0 does... At least I'm not crazy...

    Thanks again...

    --
    Sean Dotson, PE
    Autodesk Inventor Certified Expert
    http://www.sdotson.com
    http://www.sdotson.com/forums/
    Check the Inventor FAQ for most common questions
    www.sdotson.com/faq.html
    -----------------------------------------------------------------------
    "TomB" <> wrote in message
    news:...
    > I'm not familiar with Chili.Upload, but I assume it's the same as other
    > uploaders.
    >
    > Once you access the objects form objects, Request.Form will no longer be
    > available. Take a look at the Chili.Upload docs' It'll likely have it's

    own
    > way of accessing the other form items. Something
    > like....Upload.Form("description") I would suspect.
    >
    > TomB
    >
    > "Sean Dotson" <sean dotson at comcast dot net> wrote in message
    > news:...
    > > I have a form that passes variables to an asp file and then uploads a

    > file.
    > > For some reason the request.form is not getting the info from the form.
    > > It's returning blanks. Any insight would be appreciated....
    > >
    > > Here is the asp file
    > >
    > > <HTML>
    > > <HEAD>
    > > <TITLE>File Upload Results</TITLE>
    > >
    > > <BODY>
    > > <font color=#000000><b>Files Uploaded Status:</b></font><br><br>
    > >
    > > <%
    > >
    > > Set Upload = server.createObject("Chili.Upload.1")
    > >
    > > Upload.AllowOverwrite = True ' Generate unique names
    > > 'Upload.SizeLimit = 150000 ' Truncate files above 50KB
    > > On Error Resume Next
    > >
    > > MyArray = Split(Upload.SourceFileName, "\")
    > > FName = MyArray(UBound(MyArray))
    > >
    > > If Upload.SourceFileExtension = ".pdf" or Upload.SourceFileExtension =
    > > ".zip" Then
    > >
    > > If Upload.FileSize< 3000000 Then
    > >
    > > UpldAllowed=True
    > >
    > > Else
    > > UpldAllowed=False
    > >
    > > End If
    > >
    > > Else
    > >
    > > UpldAllowed=False
    > >
    > > End If
    > >
    > > If Upload.SourceFileExtension = ".gif" or Upload.SourceFileExtension or
    > > ".jpg" or Upload.SourceFileExtension or ".png" Then
    > >
    > > If Upload.FileSize< 150000 Then
    > >
    > > UpldAllowed=True
    > >
    > > Else
    > > UpldAllowed=False
    > >
    > > End If
    > >
    > > Else
    > >
    > > UpldAllowed=False
    > >
    > > End If
    > >
    > > If UpldAllowed=False Then
    > > Response.Write "<font color=red><b>Your file is either of an disallowed
    > > type or is too large. Please <a href=upload.asp>try
    > > again</a></b></font><br>"
    > > Else
    > > Upload.SaveToFile(Server.mapPath("/") & "/" & "/iparttest/upload/" &

    > FName)
    > > Response.Write "<font color=#000000><b>File: </b></font>" &
    > > Upload.SourceFileName & " <font color=#009900><b>--Size:" &

    > Upload.FileSize
    > > &" Bytes -- </b></font> <a target=_blank
    > > href=http://www.sdotson.com/iparttest/upload/" & FName & ">Click to
    > > Test</a><br>"
    > > Response.Write "<br>Copy and paste the following to use your image/file

    > in
    > > the forum:<br><br>"
    > >
    > > If Upload.SourceFileExtension = ".pdf" or Upload.SourceFileExtension =
    > > ".zip" then
    > > Response.Write "<b><font
    > > color=red>http://www.sdotson.com/iparttest/upload/" & FName &

    > "</b></font>"
    > > Else
    > > Response.Write "<b><font
    > > color=red>http://www.sdotson.com/iparttest/upload/" & FName &
    > > "</b></font>"
    > > End If
    > >
    > > End If
    > >
    > > Upload.Close
    > >
    > > Set Conn = Server.CreateObject("ADODB.Connection")
    > > Conn.Open
    > >

    "driver={MySQL};server=localhost;database=username","username","password"
    > >
    > > response.write "stuff"
    > > response.write "Description="
    > > response.write (request.form("description"))
    > >
    > > set the variables
    > > strImageURL = ""
    > > strFilename = FName
    > > strDescription = request.form("description")
    > > strAuthor = request.form("author")
    > > strCategory = request.form("category")
    > > strIsVerified = "False"
    > > strUpdateDate = Date
    > >
    > > sql = "INSERT INTO iparts
    > > (imageurl,filename,description,author,category,isverified,updatedate)

    > VALUES
    > > ('" & strImageURL & "','" & strFilename & "','" & strDescription & "','"

    &
    > > strAuthor & "','" & strCategory & "','" & strIsVerified & "','" &
    > > strUpdateDate & "')"
    > > Conn.Execute(sql)
    > > Conn.Close
    > >
    > > %>
    > >
    > > </BODY>
    > > </HTML>
    > >
    > >
    > > _____________________________________________
    > >
    > >
    > > and here is the form:
    > >
    > > <html>
    > >
    > >
    > > <FORM METHOD="POST" ENCTYPE="multipart/form-data"

    > ACTION="addnewipart.asp">
    > >
    > > <table border="0">
    > > <tr>
    > > <td>iPart to Upload:</td>
    > > <td><INPUT TYPE="FILE" NAME="FILE1"></td>
    > > </tr>
    > > <tr>
    > > <td>Your Name:</td>
    > > <td><input type="text" name="author" size="50"></td>
    > > </tr>
    > > <tr>
    > > <td>Description:</td>
    > > <td><input type="text" name="description" size="50"></td>
    > > </tr>
    > > <tr>
    > > <td>Select a Category - <a href="categoryhelp.html">Help</a></td>
    > > <td> <SELECT NAME="category">
    > > <OPTION value="hydraulics">Hydraulics
    > > <OPTION value="pneumatics">Pneumatics
    > > <OPTION value="fasteners">Fasteners
    > > <OPTION value="hardware">Hardware
    > > <OPTION value="powertransmission">Power Transmission
    > > <OPTION value="fasteners">Fasteners
    > > <OPTION value="fasteners">Fasteners
    > > </SELECT>
    > > </td>
    > > </tr>
    > > <tr>
    > > <td></td>
    > > <td><input type="submit" name="submit" value="Upload iPart"></td>
    > > </tr>
    > > </table>
    > >
    > > </form>
    > >
    > > </html>
    > >
    > >
    > >
    > > --
    > > Sean Dotson, PE
    > > Autodesk Inventor Certified Expert
    > > http://www.sdotson.com
    > > http://www.sdotson.com/forums/
    > > Check the Inventor FAQ for most common questions
    > > www.sdotson.com/faq.html
    > > -----------------------------------------------------------------------
    > >
    > >

    >
    >
    Sean Dotson, May 5, 2004
    #3
    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. The LoxFather

    C plus plus vs C Sharp

    The LoxFather, Aug 9, 2003, in forum: C++
    Replies:
    23
    Views:
    9,192
  2. The LoxFather

    C plus plus vs C Sharp

    The LoxFather, Aug 9, 2003, in forum: C Programming
    Replies:
    23
    Views:
    1,379
  3. Replies:
    1
    Views:
    923
    Gabriel Genellina
    Nov 25, 2006
  4. Rahul
    Replies:
    9
    Views:
    417
    Andrey Tarasevich
    Mar 25, 2008
  5. furqan shaikh

    c plus plus code comparator

    furqan shaikh, Nov 7, 2008, in forum: C++
    Replies:
    6
    Views:
    814
    red floyd
    Nov 12, 2008
Loading...

Share This Page