request.form & binaryRead - error !

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default request.form & binaryRead - error !

    hi everybody !
    now i have finally managed to build a upload/download file-part in my
    application, and it's working just fine, except for one detail.
    i use a simple form where the user can choose a file to upload. a also
    have a checkbox that should be checked if the file is a 'released'
    version, and unchecked if it is a preview/work in progress. i want the
    value of this checkbox to be passed to the Insert file and inserted
    into the database.

    I get the message: Cannot call BinaryRead after using Request.Form
    collection.

    I've read about it and realised that i can't use Request.Form when i
    use binary read/write.

    i just want each file in the database to have a true/false status in
    the 'Released'-field in the database. now every file is 'false' since
    i can't pass the value of the checkbox.

    is there an easy way of working around this ? i've seen a few things
    on the web but haven't found anything that works for me yet.
    code included below:
    --------------------------------------------------------------------------
    <!-- insert.htm -->
    <html>
    <head>
    <title>Inserts files into Database</title>
    <style>
    body, input { font-family:verdana,arial; font-size:10pt; }
    </style>
    </head>
    <body>
    <p align="center">
    <b>Inserting files into Database</b><br>
    <a href="show.asp">To see uploaded files click here</a>
    </p>

    <table border="0" align="center" cellpadding = "10">
    <tr>
    <form method="POST" enctype="multipart/form-data"
    action="Insert.asp">
    <td><p>File :</p></td>
    <td><input type="file" name="file" size="40"></td>
    </tr><tr>

    <td><p>Released :</p></td>
    <td><input type="checkbox" name="check"></td>
    </tr><tr>
    <td></td>
    <td></td>
    </tr><tr>
    <td> </td>
    <td><input type="submit" value="Submit"></td></tr>
    </form>
    </tr>
    </table>

    </body>
    </html>
    ------------------------------------------------------------------------------
    <!--#Include File="Connect.asp" -->
    <% ' Insert.asp %>
    <!--#include file="Loader.asp"-->
    <%
    Response.Buffer = True

    Dim checked
    'checked = Request.Form("check") 'NOT POSSIBLE HERE


    ' load object
    Dim load
    Set load = new Loader

    ' calling initialize method
    load.initialize

    ' File binary data
    Dim fileData
    fileData = load.getFileData("file")
    ' File name
    Dim fileName
    fileName = LCase(load.getFileName("file"))
    ' File path
    Dim filePath
    filePath = load.getFilePath("file")
    ' File path complete
    Dim filePathComplete
    filePathComplete = load.getFilePathComplete("file")
    ' File size
    Dim fileSize
    fileSize = load.getFileSize("file")
    ' File size translated
    Dim fileSizeTranslated
    fileSizeTranslated = load.getFileSizeTranslated("file")
    ' Content Type
    Dim contentType
    contentType = load.getContentType("file")
    ' No. of Form elements
    Dim countElements
    countElements = load.Count




    ' destroying load object
    Set load = Nothing
    %>

    <html>
    <head>
    <title>Inserts files into Database</title>
    <style>
    body, input, td { font-family:verdana,arial; font-size:10pt; }
    </style>
    </head>
    <body>
    <p align="center">
    <b>Inserting Binary Data into Database</b><br>
    <a href="show.asp">To see uploaded files click here</a>
    </p>

    <table width="700" border="1" align="center">
    <tr>
    <td>File Name</td><td><%= fileName %></td>
    </tr><tr>
    <td>File Path</td><td><%= filePath %></td>
    </tr><tr>
    <td>File Path Complete</td><td><%= filePathComplete %></td>
    </tr><tr>
    <td>File Size</td><td><%= fileSize %></td>
    </tr><tr>
    <td>File Size Translated</td><td><%= fileSizeTranslated %></td>
    </tr><tr>
    <td>Content Type</td><td><%= contentType %></td>
    </tr><tr>
    <td>No. of Form Elements</td><td><%= countElements %></td>
    </tr>

    </table><br><br>

    <p style="padding-left:220;">
    <%= fileName %> data received ...<br>
    <%
    ' Checking to make sure if file was uploaded
    If fileSize > 0 Then


    ' Recordset object
    Dim rs
    Set rs = Server.CreateObject("ADODB.Recordset")

    rs.Open "Files", Con, 2, 2

    ' Adding data
    rs.AddNew
    rs("FileName") = fileName
    rs("File Size") = fileSize
    rs("File Data").AppendChunk fileData
    rs("Content Type") = contentType
    rs("Project") = Session("Project")
    rs("Author") = Session("Author")
    rs("UDate") = NOW()
    'rs("Released") = checked 'HOW DO I SOLVE THIS ???
    rs.Update

    rs.Close
    Set rs = Nothing

    Response.Write "<font color=""green"">File was successfully
    uploaded..."
    Response.Write "</font>"
    Else
    Response.Write "<font color=""brown"">No file was selected for
    uploading"
    Response.Write "...</font>"
    End If


    If Err.number <> 0 Then
    Response.Write "<br><font color=""red"">Something went wrong..."
    Response.Write "</font>"
    End If
    %>
    </p>

    <br>
    <table border="0" align="center" cellpadding = "10">
    <tr>
    <form method="POST" enctype="multipart/form-data"
    action="Insert.asp">
    <td><p>File :</p></td>
    <td><input type="file" name="file" size="40"></td>
    </tr><tr>

    <td><p>Released :</p></td>
    <td><input type="checkbox" name="check"></td>
    </tr><tr>
    <td></td>
    <td></td>
    </tr><tr>
    <td> </td>
    <td><input type="submit" value="Submit"></td></tr>
    </form>
    </tr>
    </table>

    </body>
    </html>
    --------------------------------------------------------------------------
    THANKS !!!
    Fredrik/Sweden Guest

  2. Similar Questions and Discussions

    1. Request.BinaryRead
      Hi, I am migrating my ASP application from IIS5 environment to IIS6. My problem is, i get an error Request object error 'ASP 0104 : 80004005'...
    2. Cannot use the generic Request collection after calling BinaryRead
      hI, Task is to save the contents of an image ie .jpg/.gif file to the SQL Server. To accomplish this I open the file and save the contents using...
    3. Error Request.BinaryRead in IIS 5.0 on Windows Nt 2000 SP3
      Sometimes when loading binary files with Request.BinaryRead IIS on the log gives me the following Error (I have analyzed IIS Log with Web Trend...
    4. Error on Request.BinaryRead in IIS 6.0 (Win 2003)
      I have a VBscript that I use to upload files onto the server. The script works fine on IIS 5.0 but on IIS 6.0 on Windows 2003 I get an error when...
    5. Unspecified Error (80004005) executing Request.Form()
      There is a limit to the amount of data you can post through a form. For a file of that size you probably need to treat it as an upload. ...
  3. #2

    Default Re: request.form & binaryRead - error !

    that's right, you can't use BinaryRead and Request.Form in the same
    instance. well known fact.

    do you have an upload component available to you? I assume not if you've
    had to do this in script... but they're a LOT less hassle.




    ________________________________________
    Atrax. MVP, IIS
    [url]http://rtfm.atrax.co.uk/[/url]

    newsflash : Atrax.Richedit 1.0 now released.
    [url]http://rtfm.atrax.co.uk/infinitemonkeys/components/Atrax.RichEdit/[/url]

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Atrax Guest

  4. #3

    Default Re: request.form & binaryRead - error !

    hi again !
    well, i know there are lots of different components out there for free.
    but i wanted to do as much as possible by myself, and i got this working
    fine except for this detail.
    i just want the value of the checkbox to be passed to the the next page,
    that's all. isn't there some way of working around this ? can it be done
    in asp ? can i use javascript or something to make the variable known
    globaly ?

    Fredrik - Sweden

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Fredrik Holm Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139