SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Request.form comes in conflict with the CLSupload class

    hey guys, im trying to send a form to the same page, it works fine until i came to the part i needed to add the CLSupload class in order to do some image checks.

    my HTML code:
    Code:
    <!--#INCLUDE FILE="clsUpload.asp"-->
    <form method="post" enctype="multipart/form-data" action="add_story.asp"
    ...
    <input type="submit" name="sendForm" value="send"/>
    </form>
    the ASP code:
    Code ASP:
    if Request.Form("sendForm") = "send" Then
    ' do stuff..
    end if

    The problem is, when i use Request.Form("sendForm") = send it doesnt do anything when i press send, not even errors.

    When i do if Upload.Fields("sendForm").Value = "send" Then
    the error is: Object required: 'Upload'

    when i do :
    Set Upload = New clsUpload
    and then
    if Upload.Fields("sendForm").Value = "send"
    the error is that the enctype/multipart-data was not recieved
    (and it really was not received because the Set Upload = New clsUpload is not inside the IF statement, but if its inside the IF statement then its Object required: 'Upload')

    So, can any1 give me any ideas on how can i achieve this in some way?
    thanks

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Can you show more of your HTML form please?
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    sure this is the complete form

    Code:
    <form name="mdogs" method="post" enctype="multipart/form-data" action="UploadStories.asp" onreset="return confirm('האם אתה בטוח?')" onsubmit="return checkfrm()">
    <table border="2" align="center">
    <tr>
    <td> תמונת המאמר </td>
    <td> <input type="file" name="file1" /></td>
    </tr>
    <tr>
    <td> כותרת המאמר </td>
    <td> <input dir="ltr" type="text" name="desc1" /> </td>
    </tr>
    <tr>
    <td> <input type="submit" name="sendForm" value="send"/> </td>
    <td> <input type="reset" value="נקה"/> </td>
    </tr>
    </table>
    </form>

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,029
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    It's because you can't use request.form("sendform") to check the value of a form element that is part of a multipart form. You have to use your uploader class to inspect any form element.

    That might not make sense so let me know if you understand that.
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i think i understand what u say, altho i already tried it...

    with the uploader class it would look like that:

    Code:
    <!--#INCLUDE FILE="clsUpload.asp"-->
    Set Upload = New clsUpload
    if upload.fields("sendForm").Value = "send" then
    ' upload
    end if
    the problem is once u do the set upload = new clsUpload outside of the IF statement, then it will throw an error that multipart/data was not received, but inside the IF statement then i wont be able to use the upload.fields("sendform").value thing at all...

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,029
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Well then it must be something simple like the way you instantiate the Upload object.

    The reason you don't get an error with the following is because Request.Form("sendForm") = nothing so nothing ever happens:
    Code:
    if Request.Form("sendForm") = "send" Then
    ' do stuff..
    end if
    The reason you get an object required error for if Upload.Fields("sendForm").Value = "send" is because the Upload object doesn't exist. The only thing I can suspect is that maybe the way you have the program flow on the add_story.asp page.

    It should work the way you're using it so I'm not sure why it isn't. I use a different uploader than you do I'm pretty sure but the way mine works is as follows:
    Code:
    <!-- #include file="includes/upload.asp" -->
    Set Uploader = New FileUploader
    Uploader.Upload()
    
    
    'Check to see if the form was posted
    If Uploader.Form("saveto") = "disk" Then
    
        'Do some stuff...
    
    End If
    Try something like:
    Code:
    If Upload.Files.Count > 0 then
    
        'Do some stuff....
    
    end if
    EDIT: If that doesn't throw an error, try something simple like response.write Upload.Files.Count
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    sorry it took me awhile to get back to this topic, i've been around some other stuff...

    This way didn't work out awasson, any other ideas on how can i achieve this? i'd really like to reduce the amount of pages my website got

  8. #8
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <!--#INCLUDE FILE="clsUpload.asp"-->
    Set Upload = New clsUpload
    if upload.fields("sendForm").Value = "send" then
    ' upload
    end if

    should be

    <!--#INCLUDE FILE="clsUpload.asp"-->
    Set Upload = New clsUpload
    if upload.form("sendForm").Value = "send" then
    ' upload
    end if



    Good Luck,
    <snip/>
    Last edited by Mittineague; Dec 10, 2010 at 04:16. Reason: Please use your signature for your links.

  9. #9
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hey, thanks for the reply, but i got it solved in another way

    using the previous code i tried brought up the custom error lewis moten put, saying multipart/data was not recieved, so i simply removed all the lines regarding the mentioned custom error and it started working


Bookmarks

Posting Permissions

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