Unspecified error with simple upload and ASPUpload

Discussion in 'Classic ASP' started by KenBTDC, Jul 30, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have tried to convince support at DASP that there is nothing wrong with the code below. They assure me there is. If I try to upload a 2KB file I receive the following error:



    Persits.Upload.1 error '800a0001'

    Unspecified error

    /common/scrUploadImage.asp, line 50


    Line 50 is bold. If anyone can help it would be most appreciated.

    Thanks

    HERE IS THE CODE OF THE PAGE THAT SENDS THE REQUEST:

    <FORM METHOD="POST" ENCTYPE="multipart/form-data" action="scrUploadImage.asp">
    <input name="file1" type="file">
    <input type="submit">
    </form>




    HERE IS THE CODE OF THE PAGE THAT RECEIVES THE REQUEST:

    Set objUpload = Server.CreateObject("Persits.Upload")
    Set objImage = Server.CreateObject("Persits.Jpeg")

    dim fs,fname
    set fs=Server.CreateObject("Scripting.FileSystemObject")

    intType=1
    strMyVar = "MyDir"


    SELECT CASE intType

    CASE 1
    strRootFolder = Server.MapPath("../images/" & strMyVar & "\"
    strRootFolderVirtual = "..images/" & strMyVar & "/"

    CASE 2


    END SELECT



    Response.write "ROOT DIR:" & (strRootFolder) & "<br>"
    Response.write "VIRTUAL DIR: " & (strRootFolderVirtual) & "<br>"

    If fs.FolderExists(strRootFolder)=false then
    fs.CreateFolder(strRootFolder)
    fs.CreateFolder(strRootFolder & "tn\")
    End If

    count = objUpload.Save(strRootFolder)

    For Each File in objUpload.Files
    Response.Write File.Name & "= " & File.Path & " (" & File.Size &" bytes)<BR>"
    'fs.
    Next

    set fs = Nothing
    set objUpload = Nothing
    set objImage = Nothing
     
  2. Hi,
    This is a handy tool, I've used it a lot on DASP servers.
    Thing is, you should not use some of the settings and you should create error trapping.

    I'll offer some tips:
    1) Remove all Virtual directives.
    2) Use exact paths. Look in your DASP Control Panel for your sites path.
    Example...
    On Error Resume Next
    Upload.OverwriteFiles = False
    Upload.Save "E:\web\wisemx\htdocs\fileup\files"
    3) I'd get rid of "count" and DIM something you can use better with that "case".
    Example...
    For Each File in Upload.Files
    If Not isExtensionValid(File.FileName) Then
    File.Delete
    Response.write "Invalid File Extension : " & File.FileName
    End If
    Next
    Function isExtensionValid(filename)
    ' Get the Extension of the File
    arrTemp = split(filename,".")
    extension = arrTemp(Ubound(arrTemp))
    Select Case extension
    ' This is the list of valid extensions
    case "gif","jpg","jpeg","png","vmf","zip", "pdf", "rar", "7z"
    isExtensionValid = true
    case else
    isExtensionValid = false
    End Select
    End Function

    I used to have a lot of fun with this but it is getting harder for me to code Classic ASP...
    No matter, I will do my best to help you with this.
    All the best,
    Mark
     
  3. I have tried all that you suggested.

    1. I added the line On Error Resume Next
    RESULT: Code executes till the end but no file is uploaded

    2. Hard coded the exact path. No virtual directives used. Removed the count.
    RESULT: Exactly same error message

    I didn't try checking the extension yet but I will once I can get the file to upload.

    I believe that the code I have used is 100% valid and I believe there may be a level of configuration on the DASP servers that is required in order to allow the file to be uploaded. Is it possible?
     
  4. ...I don't think you have to change anything session related unless the file is over 20MB.

    I used this component on DASP servers to allow hundreds of users to upload raw images for Softimage 3D modeling. (Raster and Vector)

    If you want I can dabble with this again and create an example.
    Just list all the expectations you have for it, i.e. upload image, rename, etc.

    btw, do you need to do this with Classic ASP?
    All the best,
    Mark
     
  5. Hi Mark,

    I appreciate your help very much. What I am trying to do is:

    1. The user selects an image to upload (*.gif, *.jpg, *.png) that must be 50KB or less

    2. The image is saved to a sub-folder unique to the user of a folder called Images

    3. A thumbnail of the image is created in a sub folder (called 'tn') of that sub-folder. The thumbnail must be:
    a. No more than 128 pixels high
    b. No more than 128 pixels wide
    c. The aspect ratio I will keep the same

    Yes, I am 'stuck' in classic ASP. I really want to move on but am so busy. I have little time to dedicate myself to full-time development in my job and commit to spending the time learning new coding :(
     
  6. ...I've got it working on one of the test servers here, just need to finish the thumbnail part.
    All the best,
    Mark
     
  7. Cheers Mark
     
  8. Update: I've spent too much time on this, have to get back to the Webcasts.
    I'm attaching the code, a mini site, and some notes.
    Everything works as is except for the thumbnail creation.
    The folder with notes in it are the code samples you get when you purchase the actual components.
    The files in the root folder should be self explanatory, those are my code.
    All the best,
    Mark
     

    Attached Files:

  9. Hi Mark,

    Thanks for your help - it is really appreciated. I will look at the code and see what I can do with it.
     
  10. OK,

    Figured out the problem.

    There was an include that that was being imported into the page - it is a standard header used in all pages within the site. Within that include file was an IF...Then... statement that included a reference to a FORM object. On all other pages, whether or not there is a FORM object, this does not present any problems but now I know that with the ASPUpload object there can be absolutely no references to any standard FORM objects whatsoever (apart from using the standard reference to FORM objects for 'multipart/form-data' forms).

    Thanks for your help Mark - the code you present is very helpful.

    Cheers

    :)
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page